Crone Tab


It is a utility,it is used to Schedule the script ( backup ) particular point of time.

crontab stands for "cron table," because it uses the job scheduler cron to execute tasks; cron itself is named after "chronos," the Greek word for time.


Cron Tab Format :

<minutes><hours><day><month><week> cron.sh( cron file name );


Cron Tab Commands:

1. $ Crontab -e

           -  To enter the script( data ) in empty file or existing file.

2. $ Crontab -l

            - To check how many lines in the file.

3. $ Crontab -r 

               -   To Remove your crontab, effectively un-scheduling all crontab                            jobs.

4. sudo crontab -u slm -e

            - Edit the crontab of the user named slm. The -u option requires                        administrator privileges, so the command is executed using sudo.


5. sudo crontab -u saleem -l

             - View the crontab of user saleem.

6. sudo crontab -u abc -r

          - Remove the crontab of user abc

7. $ Crontab -l   >  Crontab.bkp

            -  it will take backup crontab.  


Examples Of crontab Entries :

15 6 2 1 * /home/slm/backup.sh
Run the shell script /home/slm/backup.sh on January 2 at 6:15 A.M.

15 06 02 Jan * /home/slm/backup.sh
Same as the above entry. Zeroes can be added at the beginning of a number for legibility, without changing their value.

0 9-18 * * * /home/carl/hourly-archive.sh
Run /home/carl/hourly-archive.sh every hour, on the hour, from 9 A.M. through 6 P.M., every day.

0 9,18 * * Mon /home/wendy/script.sh
Run /home/wendy/script.sh every Monday, at 9 A.M. and 6 P.M.

30 22 * * Mon,Tue,Wed,Thu,Fri /usr/local/bin/backup
Run /usr/local/bin/backup at 10:30 P.M., every weekday.


Cronetab Options :

-u   :

Append the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines "your" crontab, i.e., the crontab of the person executing the command. Note that su can confuse crontab and that if you are running it inside of su you should always use the -u option for safety's sake. The first form of this command is used to install a new crontab from some named file, or from standard input if the file name is given as "-".

-l :

Display the current crontab

-r :

Remove the current crontab.

-e :

Edit the current crontab, using the editor specified in the VISUAL or EDITOR environment variables

-i :

Same as -r, but gives the user a "Y/n" prompt before actually removing the crontab

-s :
SELinux only: appends the current SELinux security context string as an MLS_LEVEL setting to the crontab file before editing or replacement occurs. See your SELinux documentation for details.





No comments:

Post a Comment