Breaking

How to scheduling Crontab for backup files and directories in linux


1. Install crontab

In centos,redhat:

            # yum install cron*

2. Open crontab.

                  # crontab -e


                                field                    allowed values
                                ------------            -------------------
                                   minute                   0-59
                                   hour                       0-23
                                   day of month         1-31
                                   month                    1-12 (or names, see below)
                                   day of week           0-7 (0 or 7 is Sun, or use names)




 15      16      *       *       1       /bin/tar -czvf /Backup-Folder/Project-Folder-MON.tar.gz       /Project-Folder




The 'Project-Folder' will backup every Monday - every month - every day at 04:15 PM to 'Backup-Folder' under '/' with the name 'Project-Folder-MON.tar.gz'.


-c : Create
-z : Gzip
-v : Verbose
-f : File

3. Save the file


4. List crontab


            # crontab -l


5. Remove crontab


            # crontab -r


6. Restart crontab


            # service crond restart


7. Add crontab on startup


            # chkconfig crond on


How to schedule crontab for other users



Open crontab with username and add the scheduler and restart the service.


            # crontab -e -u username


How to deny a user from crontab



Open crontab.deny file and add the user you want to deny. save the file and restart the service.


            # vim /etc/crond.deny



No comments:

Powered by Blogger.