If we want to make a crontab backup we can insert the following lines into crontab (crontab -e)
#------------------------------------------------------------------------------
# Write out crontab file daily for backup
00 18 * * * $HOME/scripts/crontab_backup.ksh > $HOME/logs/crontab_backup.log 2>&1
#------------------------------------------------------------------------------
# Cleanup files
#
12 07 * * * find $HOME/logs/* -name "*" -mtime +30 -exec rm {} \; > /dev/null 2>&1
Where the $HOME/scripts/crontab_backup.ksh script contains of the following code:
#!/bin/ksh
LOG=$HOME/logs/crontab.`date +%y%m%d_%H:%M`
crontab -l > $LOG
# EOF
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment