Cron Job at Specific Time in Linux

Last updated on Jan 2, 2020 in Linux

To schedule a task to be run in a specific time in Linux can be done with cron jobs. For example, you might want to run backup process at midnight or at 3:00 AM.

Open Crontab

Open crontab file in your favorite text editor:

$ vim /etc/crontab

Set Up Timing in the Crontab

Let’s assume that the script to be run is /home/theuser/backup.sh, and we want it to be called every night at 3:15 AM. In crontab, add following line to the end:

15 3 * * * /home/theuser/backup.sh
  • 15 stands for minute, which defines the “run when the minute is 15”
  • 3 stands for hour, which defines the “run when the hour is 3 (AM)”. In case of 3:00 PM, you should enter 15 because crontab uses 24 hour format.
  • other entries * * * are for the day, month and week accordingly. This means that the script is run every day, every month and every week. Read more about the format: Crontab Format in Linux