mod_cron errors

I have mod_cron fresh from subversion, I've added it to my ejabberd.cfg file using the following line:

{mod_cron, []},

However when I restart my server I get this error in my log file...

E(<0.14902.19>:gen_mod:93) : {undef,
[{ejabberd_commands,unregister_commands,
[[{ejabberd_commands,cron_list,
[cron],
"List tasks scheduled in a host",[],
mod_cron,cron_list,
[{host,string}],
{tasks,
{list,
{task,
{tuple,[{id,integer},{task,string}]}}}}},
{ejabberd_commands,cron_del,
[cron],
"Delete this task from the schedule",[],
mod_cron,cron_del,
[{taskid,integer}],
{res,rescode}}]]},
{mod_cron,stop,1},
{gen_mod,stop_module_keep_config,2},
{lists,foreach,2},
{ejabberd_app,prep_stop,1},
{application_master,prep_stop,2},
{application_master,loop_it,4}]}

=ERROR REPORT==== 2009-01-19 16:12:14 ===
E(<0.28087.22>:gen_mod:67) : {undef,
[{ejabberd_commands,register_commands,
[[{ejabberd_commands,cron_list,
[cron],
"List tasks scheduled in a host",[],
mod_cron,cron_list,
[{host,string}],
{tasks,
{list,
{task,
{tuple,[{id,integer},{task,string}]}}}}},
{ejabberd_commands,cron_del,
[cron],
"Delete this task from the schedule",[],
mod_cron,cron_del,
[{taskid,integer}],
{res,rescode}}]]},
{mod_cron,start,2},
{gen_mod,start_module,3},
{lists,foreach,2},
{ejabberd_app,start,2},
{application_master,start_it_old,4}]}

I've been trying to get a daily backup working using this module which has also been failing, the page on this site. Can anyone suggest what I can do to get this working?

I am using ejabberd 2.0.2 for linux downloaded from this site. Is this module compatible with the 2.x series?

Can anyone suggest a method for getting a daily database dump? I've tried using standard Linux cron without success.

Recent mod_cron requires ejabberd trunk. Get older mod_cron

dnel wrote:

I am using ejabberd 2.0.2 for linux downloaded from this site. Is this module compatible with the 2.x series?

Did you check the README.txt of mod_cron? It says: "Requirements: ejabberd trunk SVN 1635 or newer".

Once an ejabberd release includes such support, mod_cron's README.txt will be updated to mention what ejabberd releases are supported. It will probably some ejabberd 2.1.

Fortunately you have an easy solution to get mod_cron to work with ejabberd 2.0.x: use a lightly older mod_cron. I think mod_cron SVN 699 will work with ejabberd 2.0.2. You can get that older code with

svn up -r 699

Remember to enable mod_cron only in one vhost. If you have several vhosts, you should use instead something like this at the end of ejabberd.cfg:

{host_config, "jabber.example.org",
 [{{add, modules}, [
                    {mod_cron, []}
                   ]
  }
 ]}.

If you get mod_cron running with the simple configuration you mentioned, you can later try this:

{modules, [
  {mod_cron, [{tasks, [
    {1, days, file, rename, ["/tmp/ejabberd/backups/last.backup", 
                             "/tmp/ejabberd/backups/previous.backup"]},
    {1, days, mnesia, backup, ["/tmp/ejabberd/backups/last.backup"]}
  ]}]},
  ...
 ]}.

With that configuration, after 1 day you start ejabberd, you will see in the logs:

=ERROR REPORT==== 19-Jan-2009::22:21:54 ===
E(<0.350.0>:mod_cron:101) : Error in scheduled task file:rename["/tmp/ejabberd/backups/last.backup",
                                                                "/tmp/ejabberd/backups/previous.backup"]:
enoent

=INFO REPORT==== 19-Jan-2009::22:21:54 ===
I(<0.351.0>:mod_cron:103) : Scheduled task mnesia:backup["/tmp/ejabberd/backups/last.backup"] finished ok

And the file last.backup is created.

The next day you will see something like this:

=INFO REPORT==== 19-Jan-2009::22:22:24 ===
I(<0.374.0>:mod_cron:103) : Scheduled task file:rename["/tmp/ejabberd/backups/last.backup",
                                                       "/tmp/ejabberd/backups/previous.backup"] finished ok

=INFO REPORT==== 19-Jan-2009::22:22:24 ===
I(<0.375.0>:mod_cron:103) : Scheduled task mnesia:backup["/tmp/ejabberd/backups/last.backup"] finished ok

which means last.backup was renamed to previous.backup, and a new backup was stored in last.backup.

It would be even better if the backups were named like "ejabberd-2009-01-19-22-22-24.backup", but that doesn't seem possible with mod_cron.

Quote: Did you check the

Quote:

Did you check the README.txt of mod_cron? It says: "Requirements: ejabberd trunk SVN 1635 or newer".

Yes I did, but like probably most admins of public servers I use stable release versions I do not keep a copy of the ejabberd development tree and I do not know what 2.0.2 resolves to in SVN revision numbering, if this information is available I have been unable to find it. It would be helpful to us users that are not involved in development to advise that it is broken in all current release versions.

I have recompiled from revision 699 as you suggested which has improved things, the simple module loader without parameters works ok but when I enter the file rename and backup commands as you suggested (copy/paste) I get this error in my log

Quote:

E(<0.8731.23>:gen_mod:67) : {undef,
[{tasks,start,
["myhost.com",
[{1,days,file,rename,
["/tmp/ejabberd/backups/last.backup",
"/tmp/ejabberd/backups/previous.backup"]},
{1,days,mnesia,backup,
["/tmp/ejabberd/backups/last.backup"]}]]},
{gen_mod,start_module,3},
{lists,foreach,2},
{ejabberd_app,start,2},
{application_master,start_it_old,4}]}

Any further assistance would be appreciated.

Check the configuration

I think you have put something like this, which is wrong:

{modules,
 [

  {tasks, [
    {1, days, file, rename, ["/tmp/ejabberd/backups/last.backup",
                             "/tmp/ejabberd/backups/previous.backup"]},
    {1, days, mnesia, backup, ["/tmp/ejabberd/backups/last.backup"]}
  ]},

  {mod_adhoc,    []},
  ...
 ]}.

This is correct:

{modules,
 [

  {mod_cron, [{tasks, [
    {1, days, file, rename, ["/tmp/ejabberd/backups/last.backup",
                             "/tmp/ejabberd/backups/previous.backup"]},
    {1, days, mnesia, backup, ["/tmp/ejabberd/backups/last.backup"]}
  ]}]},

  {mod_adhoc,    []},
  ...
 ]}.

cheers

That seems to have done the trick, nicely spotted. Thanks for you help! :)

Syndicate content