Skip to content
Host4u Limited

Scheduled tasks (cron jobs)

Support Portal  »  Knowledgebase  »  Viewing Article
There was a problem loading the comments.
  Print

A cron job runs a command or script automatically at times you choose, for example to send a report every night or run a clean-up every hour.

Adding a cron job

  1. In cPanel, open Cron Jobs (in the Advanced section).
  2. Under Add New Cron Job, pick a ready-made time from Common Settings, such as once a day, or fill in Minute, Hour, Day, Month and Weekday yourself. A * means every. All five time boxes and the command are needed.
  3. Enter the Command to run. Use the full path to the program or script. The page shows PHP command examples.
  4. Click Add New Cron Job.

Your jobs are listed under Current Cron Jobs. To change one, click Edit, make the change and click Edit Line. To remove one, click Delete and confirm.

Where the output goes

By default cron emails you the output of every job. Under Cron Email at the top of the page you can set the address: type it in the Email box and click Update Email.

Please use a mailbox on your own account, not an external address. If a lot of cron output is relayed to other providers, they may start blocking our mail servers. Where we find cron output going to an external address, we change it to the account's default mailbox. You read that mailbox in webmail or with IMAP, using your cPanel username (not an email address) and password.

To stop the emails altogether, remove the address in Cron Email. To stop them for one job, click Edit on that job and add /dev/null 2>&1 to the end of its command, after a >.

Tips

  • Test the command on its own before you schedule it.
  • Leave enough time between runs for the last one to finish, and run jobs no more often than you need. Very frequent jobs use up your resources: see Resource usage and limits.
  • If you see a cron job you did not create, treat it as a sign of a hack. Change your passwords and open a support ticket. Our malware scanner can find jobs that run malicious scripts.

Share via
Did you find this article useful?  

Related Articles


Self-Hosted Help Desk Software by SupportPal