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.

     

  • I did

    23 13 * * * tmsh save sys ucs thisisatest2.ucs

    so it would create one a 1:23 and that just worked.

    (Still on 13.1.1.3)

    Check the time on your device maybe?

  • @Chuck,

    4 15 * * *
    - Here 4 is the minute & 15 is the hour.

    So everyday, at 03:04 PM (box timezone), the cron will get executed. See what your box timezone is. And put your cron accordingly.

  • Hey Chuck!

     

    Just as a side note, have you checked out this iApp for backups? I'm using it in multiple environments and it is working great, even on version 13.1.1.2. It will fix all of the cron jobs and you access it from the WebGUI.

     

    It will let you define how often the backup runs and also enter the credentials to the remote storage. It will send over the UCS archives and it will automatically rotate (delete old ones) up to 10 files. I'm sure this can be modified if you want. I think it works great. :)

     

    You can find it here:

     

    F5 iApp Automated Backup

     

    I hope this helps!

     

  • I'm still looking into this, but the cron job did run, just not at the desired time. I'm going to go back through the configs because this does look like a timezone setting issue, just not the normal use of UTC. Here are the details:

    From Crontab:

    29 15 * * * /root/backup.sh

    Timestamp from file:

    -rw-r--r--. 1 root root 3.5M 2019-02-13 17:29 config-dev1.ucs

    Time Information from Guest:

    [root@DEV1:Active:In Sync] ucs date

    Thu Feb 14 08:22:44 CST 2019

    Time Server Sync Information:

    [root@DEV1:Active:In Sync] ucs ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
    

    ==============================================================================

    *TIME1 129.6.15.28 2 u 962 1024 377 0.335 0.048 0.708

    +TIME2 129.6.15.28 2 u 73 1024 377 0.346 -0.005 0.102

  • Also, hardware clock is reflecting UTC:

     

    [root@DEV1:Active:In Sync] ucs hwclock

     

    Thu 14 Feb 2019 02:31:06 PM CST -0.000367 seconds

     

  • SOLVED!

     

    I had not restarted this guest since it was built. See K14113 for the details.

     

    Thank you Dylan and jaikumar for your help.

     

  • Ahhhh glad you got to the bottom of it! I was planning on mentioning this morning to look in to time settings/zones more.

     

    Thanks for sharing the solution.

     

    If you don't mind selecting an answer so people browsing DevCentral know this issue is solved, it would be greatly appreciated!

     

    Have a good one Chuck!

     

  • 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.

     

    • Dylan_375544's avatar
      Dylan_375544
      Icon for Cirrocumulus rankCirrocumulus

      What I meant was to select an answer, like my original answer post. Once you select it as the "user selected answer" it shows as "answered" on the main page.

       

      (:

       

    • Chuck_383680's avatar
      Chuck_383680
      Icon for Cirrus rankCirrus

      Thanks. I'm still getting used to this. And, thanks again for the help!