Linux How to..

Linux How to ,Share Knowledge

TAG: Auto Backup Crontab User root Every Weeks time 04:00 a.m.


#Create Folder For Backup
mkdir /root/backup/

#Create Folder For Shell Scripts
mkdir /root/scripts/

#Create Shell Scripts File
vi /root/scripts/backup-crontab.sh

#!/bin/bash
crontab -l -u root > /root/backup/crontab-`date +%Y-%m-%d`

:wq! Save and Quit

#Chmod Permission file for Shell Scripts Allow User root – Read+Write+Execute
chmod 700 /root/scripts/backup-crontab.sh

#Add Shell Scripts Run Every Weeks time 04:00 a.m. on crontab

crontab -e

input line below :
#backup crontab every weeks
0 4 * * 0 /bin/sh /root/scripts/backup-crontab.sh

:wq! = save and quit

Success!!!!

Comments are closed.