0% found this document useful (0 votes)
85 views

Crontab

This document provides steps to set up a cron job using crontab on Linux: 1) Open a terminal and copy your shell script into the appropriate cron directory based on how often you want it to run, such as the cron.daily folder to run it daily. 2) Change the permissions of the script file to 755. 3) Add the new cron job to crontab by running crontab -e and specifying the schedule in the format of minutes hours day-of-month month day-of-week command.

Uploaded by

Athzum
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Crontab

This document provides steps to set up a cron job using crontab on Linux: 1) Open a terminal and copy your shell script into the appropriate cron directory based on how often you want it to run, such as the cron.daily folder to run it daily. 2) Change the permissions of the script file to 755. 3) Add the new cron job to crontab by running crontab -e and specifying the schedule in the format of minutes hours day-of-month month day-of-week command.

Uploaded by

Athzum
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Setting Up Cron Job Using crontab:

Step 1: Open a Terminal Window (Command Line) in Linux.

Step 2: The following is a list of cron directories: • /etc/cron.hourly • /etc/cron.daily • /etc/cron.weekly


• /etc/cron.monthly Copy your shell script ‘script.sh` or ‘script’ into one of the directories above. If you
need to run the script hourly, place your script file in the “cron.hourly” folder. For daily, place it inside
the “cron.daily” and so forth.

Step 3: Give the shell script the correct permission. For example, if script is called “script.sh”, set
permission as follows:

cd /etc/cron.daily/ chmod 755 script.sh

Step 4: Add new cron job to crontab:

crontab –e

This opens vi editor for you. Create the cron command using the following syntax:

1. The number of minutes after the hour (0 to 59) 2. The hour in military time (24 hour) format (0 to 23)
3. The day of the month (1 to 31) 4. The month (1 to 12) 5. The day of the week(0 or 7 is Sun, or use
name) 6. The command to run

You might also like