Cron jobs are perfect for repetitive tasks that need to be run on every hour, day, week, or month. To set up a Crob job on your account, do the following:
-
Click Webmin Modules and Scheduled Cron Jobs.
Click Create a new scheduled cron job.
Enter the full command to run (including command arguments) into the Command field. Don't forget to specify full paths to all binaries (e.g. /usr/local/bin/php instead of just php).
Enter a textual description into Description. This is optional but will help you identify cron jobs later on.
Select an execution schedule. The default setting will create a cron job that executes every hour. The options that you select from the list fields will set a time when the job will execute (unless you have the All option select which ignores the particular select list).
When you are done, click Create.
Please remember that you are not allowed to execute Cron jobs more often than once an hour (especially beware of selecting the All option under Minutes).
If your Cron jobs aren't working it most likely means that you're not using the full path to your chosen binary. For example, if you're scheduling something with subversion (svn), you'd need to use /usr/local/bin/svn instead of svn.
Make sure you always specify the full path to all binaries, and if you are executing a script instead, make sure the script itself uses full paths to binaries (or extend the PATH environment variable inside the script to include all locations).
You'll find that most of the common binaries are in /usr/local/bin/, so try prefacing your binary with that in your Cron job. To determine the path of a binary, just type which and the name of the binary from the terminal and press Return. So, to determine the path to curl, do this:
ross:~ root# which curl
curl is /usr/local/bin/curl
And, as you can see, the path to curl is /usr/local/bin/curl.
Testing your cron job by using the Run Now button on the Cron job editing page in Virtualmin will not tell you if your full binary paths are missing.
Due to an ancient Solaris limitation, Cron will refuse to load up Cron jobs for users with usernames that are 15 and more characters long (weird figure huh?). This means that you will be able to submit a Cron job through Virtualmin, test it there, but the job itself will not execute automatically as scheduled. The only (very clumsy) workaround currently is to restart Cron at Joyent's end, which will force your Cron job to load properly and execute as scheduled - until the next time your change it.