0

I have found a similar problem (Crontab resetting itself) but it does not provide much insight. I am new to using crontab and am having the same problem with my crontab be reverted to a previous state every-night (Not wiping but undoing two very important additions I need for backups).

I am editing the crontab from the root of a Networked attached storage drive and I am adding a script to backup to aws S3 at night and an additional script to kill the backup in the morning when everyone arrives. I placed both of them at the top of the crontab and saved. The backup kicks off on schedule and then I wake up in the morning to find it is still going when it should have been killed (reason being that the jobs are no longer in my crontab!).

Here is what my crontab keeps resetting to:

root@MyCloudXYZ root # crontab -e
0 3 * * * /usr/sbin/daily_log_upload.sh &
0 3 * * * /usr/sbin/traceroute_wd.sh &
*/30 * * * * /usr/sbin/quota_monitor &
0 */4 * * * /usr/sbin/rlog -s /usr/local/modules/files/syslog_rotate.conf
01 */8 * * * [ -f /etc/init.d/atop ] && /etc/init.d/atop rotate
30 0 * * * /usr/local/sbin/ssl_cert_job.sh start > /var/log/ssl_cert_cron.out 2>&1
0 0 * * * random_chk_central -s &
30 0 * * 1 logwdmsg -e &
0 3 * * * logwdmsg -o &
01 3 * * * /usr/local/sbin/LogDataSize.sh
00 3 * * * /usr/sbin/wd_rotate.sh
30 0 * * 1 /usr/sbin/wdappmgr_log_stats.py > /dev/null 2>&1 &
30 2 * * * /usr/sbin/stime&
0 3 * * * wd_crontab.sh&
0 4 * * * auto_fw -a -c&
0 0 * * * auto_clear_recycle_bin.sh &
30 3 * * * /usr/sbin/chk_wfs_download&
0 3 * * * auto_fw -d 1&
0 0 * * * random_check -s &
0 0 * * * expire.sh
27 21 * * * /usr/local/sbin/PullWdlogConfig.sh
27 21 * * * auto_fw -d 0 &
* * * * * sysinfo_update.sh
0 3 * * 1 getHddWhiteList.sh
# Whitespace

Changed to:

35 13 * * * /usr/local/sbin/backup_pdfs.sh > /var/log/s3_sync.log
0 5 * * * /usr/local/sbin/kill_backup.sh
0 3 * * * /usr/sbin/daily_log_upload.sh &
0 3 * * * /usr/sbin/traceroute_wd.sh &
*/30 * * * * /usr/sbin/quota_monitor &
0 */4 * * * /usr/sbin/rlog -s /usr/local/modules/files/syslog_rotate.conf
01 */8 * * * [ -f /etc/init.d/atop ] && /etc/init.d/atop rotate
30 0 * * * /usr/local/sbin/ssl_cert_job.sh start > /var/log/ssl_cert_cron.out 2>&1
0 0 * * * random_chk_central -s &
30 0 * * 1 logwdmsg -e &
0 3 * * * logwdmsg -o &
01 3 * * * /usr/local/sbin/LogDataSize.sh
00 3 * * * /usr/sbin/wd_rotate.sh
30 0 * * 1 /usr/sbin/wdappmgr_log_stats.py > /dev/null 2>&1 &
30 2 * * * /usr/sbin/stime&
0 3 * * * wd_crontab.sh&
0 4 * * * auto_fw -a -c&
0 0 * * * auto_clear_recycle_bin.sh &
30 3 * * * /usr/sbin/chk_wfs_download&
0 3 * * * auto_fw -d 1&
0 0 * * * random_check -s &
0 0 * * * expire.sh
27 21 * * * /usr/local/sbin/PullWdlogConfig.sh
27 21 * * * auto_fw -d 0 &
* * * * * sysinfo_update.sh
0 3 * * 1 getHddWhiteList.sh
  • Please post the actual text, instead of an image of it – Kevin Kruse Aug 24 '18 at 15:02
  • How are you editing your crontab? What do your edits look like? – Kevin Kruse Aug 24 '18 at 15:04
  • I added the information. I am using the crontab -e command from the root account, adding my scripts and then exiting with :wq. The backup runs but sometime, in the middle of the night, the two scripts are being removed from the crontab. – Taylor Noble Aug 24 '18 at 15:10
  • Please add the output of stat /var/spool/cron/root after it has been reverted but before you have edited it. – stark Aug 24 '18 at 15:30
  • 1
    This WD forum post describes how to make persistent crontab changes on a NAS where the crontab file is periodically overwritten. You may want to look to see if your NAS contains a /usr/local/modules/default/config.xml or /etc/NAS_CFG/config.xml file, from which the crontab is recreated. – Kevin Kruse Aug 24 '18 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.