I started this thread when I saw most of my cronjobs disappear, but I don't run Diversion.I'm wondering if it's Diversion's multiple (repeated) calls to restart dnsmasq
#!/bin/sh
#
# Add our scripts to cron job list.
#
cru a AGTxEM "15 3 * * * /jffs/AGT/scripts/regular-email"
cru a AGTxEU "3 4 * * * wl -i eth5 deauthenticate 8C:85:80:54:82:28"
cru a AGTxMQ "*/5 * * * * /jffs/AGT/scripts/send-cputemp-mqtt"
cru a AGTxBU "13 2 * * * /jffs/AGT/scripts/BackupToNAS.sh"
07-Mar 16:05:10 AX cru[4953]: Calling PID: 15454, CMD: -sh
07-Mar 16:06:08 AX cru[5284]: Args: a AGTxEM 15 3 * * * /jffs/AGT/scripts/regular-email
07-Mar 16:06:08 AX cru[5284]: Calling PID: 5283, CMD: /bin/sh./init-start
07-Mar 16:06:38 AX cru[5284]: Failed to acquire lock
07-Mar 16:06:38 AX cru[5528]: Args: a AGTxEU 3 4 * * * wl -i eth5 deauthenticate EufyDoorBell
07-Mar 16:06:38 AX cru[5528]: Calling PID: 5283, CMD: /bin/sh./init-start
07-Mar 16:07:09 AX cru[5528]: Failed to acquire lock
07-Mar 16:07:09 AX cru[5810]: Args: a AGTxMQ */5 * * * * /jffs/AGT/scripts/send-cputemp-mqtt
07-Mar 16:07:09 AX cru[5810]: Calling PID: 5283, CMD: /bin/sh./init-start
07-Mar 16:07:38 AX cru[5810]: Failed to acquire lock
07-Mar 16:07:38 AX cru[6059]: Args: a AGTxBU 13 2 * * * /jffs/AGT/scripts/BackupToNAS.sh
07-Mar 16:07:38 AX cru[6059]: Calling PID: 5283, CMD: /bin/sh./init-start
07-Mar 16:08:09 AX cru[6059]: Failed to acquire lock
07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxEM
07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxEU
07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxMQ
07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxBU
cru l
51 21 */7 * * service restart_letsencrypt #LetsEncrypt#
*/2 * * * * /etc/openvpn/server1/vpn-watchdog1.sh #CheckVPNServer1#
TxEM 15 3 * * * /jffs/AGT/scripts/regular-email #AGTxEM#
TxEU 3 4 * * * wl -i eth5 deauthenticate 8C:85:80:54:82:28 #AGTxEU#
TxMQ */5 * * * * /jffs/AGT/scripts/send-cputemp-mqtt #AGTxMQ#
TxBU 13 2 * * * /jffs/AGT/scripts/BackupToNAS.sh #AGTxBU#
Installled, running and cron jobs added fine. cronj logging fine tooI think a proper locking should use flock. Can’t test this since my router is being RMA’d, so if any brave volunteers step forward, let me know if it runs.
This version is without logging. I suppose I can change that and have both for now.Installled, running and cron jobs added fine. cronj logging fine too
It's a little smaller than the old one
Strange, /var/lock/cron.lock exists for me too. Stranger, I've never run @SomeWhereOverTheRainBow's modified script - I've always used Dave's.
/var/lock/cron.lock
is part of the normal cru
script. It should always be there apart from a very brief moment when the crontab is being updated.Indeed. I really can't guess what the writer of that script intended. It's like they started to write a locking mechanism and then gave up.I think a proper locking should use flock.
flock
, and if it can't get an exclusive lock then exit rather than carrying on.You're right. I just saw the log without checking the times. Would love to have the logging back though - may help later.This version is without logging
Haha, you wait this long to try something. I almost forgot about it.No sorry, it still doesn't work, now crond is failing
@SomeWhereOverTheRainBow : any ideas, I'm not a great writer of scripts!!!
Code:07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxEM 07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxEU 07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxMQ 07-Mar 16:31:00 AX crond[1561]: user RT-AC86U-admin: parse error at TxBU
the crontab file seems to be getting trashed ....
Code:cru l 51 21 */7 * * service restart_letsencrypt #LetsEncrypt# */2 * * * * /etc/openvpn/server1/vpn-watchdog1.sh #CheckVPNServer1# TxEM 15 3 * * * /jffs/AGT/scripts/regular-email #AGTxEM# TxEU 3 4 * * * wl -i eth5 deauthenticate 8C:85:80:54:82:28 #AGTxEU# TxMQ */5 * * * * /jffs/AGT/scripts/send-cputemp-mqtt #AGTxMQ# TxBU 13 2 * * * /jffs/AGT/scripts/BackupToNAS.sh #AGTxBU#
Alan you have to make sure you are using the script correctly.OK, I read thru the script and found that the file "/var/lock/cron.lock" already existed.
Once I deleted it, the script now works.
[ BUT - how did that file get there??? ]
elif [ "$1" = "unlock" ]; then
rm -f "$lock_file"
fi
#!/bin/sh
#
# Add our scripts to cron job list.
#
cru a AGTxEM "15 3 * * * /jffs/AGT/scripts/regular-email"
cru a AGTxEU "3 4 * * * wl -i eth5 deauthenticate 8C:85:80:54:82:28"
cru a AGTxMQ "*/5 * * * * /jffs/AGT/scripts/send-cputemp-mqtt"
cru a AGTxBU "13 2 * * * /jffs/AGT/scripts/BackupToNAS.sh"
#!/bin/sh
#
#
sh /jffs/scripts/mycron.sh &
I combined logging and locking in the original version with instructions here:I think a proper locking should use flock. Can’t test this since my router is being RMA’d, so if any brave volunteers step forward, let me know if it runs.
Looks great, that should definitely do the job. Hopefully everyone who invokes all these individual cronjobs realize it is better to do it from a separate shell script that runs in the background, than to try to invoke them as individual lines inside the main calling script itself (alternatively they can be invoked in a separate shell in the main calling script similar to this format) &.I combined logging and locking in the original version with instructions here:
Crontab jobs disappeared.
It's almost like it's inserting a folder listing in the middle of the cru statement The "*" are being globbed. It looks like the script isn't putting the required quotes around "00 2 * * Fri" for Diversion_UpdateBL, for example. @thelonelycoder ?www.snbforums.com
I think the problem is with the cru command, not the scripts that are being scheduled.Looks great, that should definitely do the job. Hopefully everyone who invokes all these individual cronjobs realize it is better to do it from a separate shell script that runs in the background, than to try to invoke them as individual lines inside the main calling script itself (alternatively they can be invoked in a separate shell in the main calling script) &.
why, you don't think daves previously posted script should work?I think the problem is with the cru command, not the scripts that are being scheduled.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!