Notes About Using Cron
################################################################################
# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
################################################################################
() Run a cronjob and use the current date/time in the command
1 0 * * * mv fileA fileA__$(date +\%m.\%d.\%C\%y_\%H:\%M:\%S).log >> /var/log/fileA_move_output_$(date +\%m\%d\%C\%y).log 2>&1
() Clean up log files based on date - Older than 6 days and then remove it
1 0 * * * find /var/log/ -name '*_output*.log' -mtime +6 -exec rm {} \; >> /var/log/Cleanupcron_output_$(date +\%m\%d\%C\%y).log 2>&1
() Run cronjob on first Saturday of month
* * 1-7 * * [ "`date +\%a`" = "Sat" ] && /home/build/test.sh >> /var/log/TEST_output_$(date +\%m\%d\%C\%y).log 2>&1
No comments:
Post a Comment