ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
    • Linux
      • Basics
      • Apache
      • Control Panels
      • FTP
      • Magento
      • Miscellaneous
      • MySQL
      • NGINX
      • PHP
      • PHP-FPM
      • Setting up Websites
      • NFS
      • VPN
      • Percona
      • SSH
      • SSL
      • Git
      • Redis
      • Elasticsearch
      • MongoDB
      • Ncdu
    • VMware ESXi
    • Windows
  • Webcelerator
  • MyUKFast
  • Home >
  • Operating systems >
  • Linux >
  • Basics >
  • Setting up cron jobs

Setting up cron jobs¶

cron is a time-based job scheduler found in most Linux based operating systems, it is used to execute jobs at regular intervals.

The easiest way to add cron jobs to your server is to use the crontab utility. The manual page for the tool can tell you all you need to know however you will likely be using -u {username} to designate a user and -e to edit the jobs.

For example crontab -u {username} -e opens {username}’s crontab for editing. Using the user bob as a demonstration, we could use the following command:

crontab -u bob -e

A typical cron job is comprised of two parts:

  • The schedule

  • The action

The Schedule¶

The schedule denotes the times that the job should be executed, unfortunately this is a little more complicated than just typing ‘every Tuesday’ but it doesn’t take too long to get used to. The schedule takes five arguments; minute/hour/day of month/month/day of week, for example:

1 0 * * *

tells cron to run the job at one minute past midnight every day of every month no matter which day of the week it is.

1 0 * * 1

Is very similar to our first example however this tells cron to run the job at one minute past midnight on Monday.

The Action¶

The second part of the cron job denotes the command to be executed at the given time. Using our examples from above

1 0 * * *     /path/to/script.sh

Would run the script at one minute past midnight.

There are several online utilities that will generate the cron job for you and most control panels will also have a user friendly interface for the system.

Next Article > Domain Name Service (DNS)

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ