Creating Cron jobs
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:
- Sign in to Virtualmin (see Account logins and important URLs).
- 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/phpinstead of justphp). - 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.
Troubleshooting Cron jobs
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.