Forum Discussion

Chuck_383680's avatar
Feb 13, 2019

Crontab for backups - Entries not running

Trying to configure a cron-based daily backup for a vCMP guest, running v13.1.1. As root, using crontab -e, I've added the following lines:

 

27 8 * * * /usr/bin/tmsh save sys ucs config1.ucs

 

29 8 * * * /usr/bin/scp /var/local/ucs/config1.ucs user@server:/backups/config1.ucs

 

After exiting, I've verified the changes have saved. Logs reflect that a change has been made. These jobs never happen based on the timestamp of the backup not changing, nor is either job recorded in the logs. I can manually run the same command, and they work successfully. Any help is appreciated.

 

  • Solution Information: The jobs were running, but not at specified times. The root cause was that the guest had not been restarted since the time zone was set, and cron was using the previous time zone. See K14113 for the details on how to restart the cron daemon.

     

  • Thanks for the link.

     

    After reading through the anacron behavior, using cron.daily isn't going to work for us. I need this backup to reach our centralized repository prior to an archival job that runs later in the night.

     

    I went through all of the files within /etc/cron.*, none of those files are running the jobs listed within the root crontab, so I get the feeling I'm missing something between editing the crontab and implementing the crontab.

     

    At this point, I may spin up a 13.0 or 12.x guest to see if the behavior exists there, as well.

     

  • I see you are on 13...

     

    There is a cron.daily file you should put the commands in.

     

    Check THIS out

     

  • Yeah if that backup.sh file is located in /root/ then it should be working... I see you had it set to run at 1:06pm, are you in central time?

     

  • Here is requested info, shell script runs via commandline. The enclosed crontab file is the default config for a new install, along with the one added backup.sh line. Is there an extra step when modifying the crontab on an F5 v/s a regular linux box?

     

    -rwxr-xr-x. 1 root root 166 2019-02-13 13:05 backup.sh

     

    backup.sh

     

    !/bin/bash

     

    /usr/bin/tmsh save sys ucs config1.ucs /usr/bin/scp /var/local/ucs/config1.ucs user@server:/backups/config1.ucs

     

    [root@DEV1:Active:In Sync] ~ crontab -l

     

    MAILTO=""

     

    1-59/10 * * * * /usr/bin/diskmonitor

     

    0 */4 * * * /usr/bin/diskwearoutstat

     

    12 17 * * * /usr/bin/updatecheck -a

     

    12 17 06 * * /usr/bin/phonehome_upload

     

    6 * * * * /usr/bin/copy_rrd save

     

    06 13 * * * /root/backup.sh

     

  • Have you tried removing "/usr/bin" and just leaving the command "tmsh save sys ucs config1.ucs"

    You could also do something like this:

    Make a bash script file in /config for example that says

    tmsh save sys ucs 

    scp -p /var/local/ucs/ root@:/var/local/ucs/

    Then just point the cron to run that.

    27 8 * * * /config/

    Hope that helps! If it does please up-vote and select this answer, it'd be greatly appreciated!

    -Dylan

    • Dylan_375544's avatar
      Dylan_375544
      Icon for Cirrocumulus rankCirrocumulus

      Can you post what you have in the bash script and on the crontab currently that isn't working?

       

    • Chuck_383680's avatar
      Chuck_383680
      Icon for Cirrus rankCirrus

      I added "/usr/bin/" only after the first attempts failed. Good idea about the bash script, just tried that also did not work. I went back through cron logs and verified that every other item in root's cron is running properly.