What's new

my crontab entries disappear after a reboot

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

dvohwinkel

Senior Member
I made my own watchdog that runs from cron to check connections. The entry survives a firewall restart but not a reboot. How can I get my entry in crontab to survive a reboot?
 
I made my own watchdog that runs from cron to check connections. The entry survives a firewall restart but not a reboot. How can I get my entry in crontab to survive a reboot?
Make a script to reload the cron settings at restart.
 
Make a script to reload the cron settings at restart.

How do I add to cron from a script? Just add to the /var/spool/crontab/{USER} file?
 
How do I add to cron from a script? Just add to the /var/spool/crontab/{USER} file?
that works. I made an init-script in /jffs/scripts/ and it adds an entry to the crontab. Thanks for the help.
 
Actually adding the init-start to /jffs/scripts/ didn't work on reboot. When I manually ran init-start it added fine, but it didn't seem to run on it's own on reboot. I was chmod 755 .. I'll put the simple thing below (init-start)

#!/bin/sh

echo "*/5 * * * * sh /jffs/scripts/firewall_watchdog.sh" >> /var/spool/cron/crontabs/dave
Any ideas why it didn't run or why it wouldn't work on reboot but would work when run manually?
 
Actually adding the init-start to /jffs/scripts/ didn't work on reboot. When I manually ran init-start it added fine, but it didn't seem to run on it's own on reboot. I was chmod 755 .. I'll put the simple thing below (init-start)

#!/bin/sh

echo "*/5 * * * * sh /jffs/scripts/firewall_watchdog.sh" >> /var/spool/cron/crontabs/dave
Any ideas why it didn't run or why it wouldn't work on reboot but would work when run manually?
I would suggest:
Code:
#!/bin/sh

cru a fwwatchdog "*/5 * * * * sh /jffs/scripts/firewall_watchdog.sh"
 
Actually adding the init-start to /jffs/scripts/ didn't work on reboot. When I manually ran init-start it added fine, but it didn't seem to run on it's own on reboot. I was chmod 755 .. I'll put the simple thing below (init-start)

#!/bin/sh

echo "*/5 * * * * sh /jffs/scripts/firewall_watchdog.sh" >> /var/spool/cron/crontabs/dave
Any ideas why it didn't run or why it wouldn't work on reboot but would work when run manually?

Interesting.. I added logger "XXXXX - Testing init-start"
to the second line of my script above .

and it didn't show up in the syslog when rebooted, but did show up when I ran init-start by hand.
@RMerlin is init-start still valid or was it deprecated ?
 
I would suggest:
Code:
#!/bin/sh

cru a fwwatchdog "*/5 * * * * sh /jffs/scripts/firewall_watchdog.sh"

Interesting.. I had not seen that before. The problem is it does not seem to be running init-start at all as the logger I put in it didn't run either.
 
Do you have JFFS scripts enabled on the Administration / System page?

yes as I also use Skynet which requires it and works fine.
 
yes as I also use Skynet which requires it and works fine.
How did you create your init-start script? Using VI on the router or upload from a PC?

Try running
Code:
dos2unix /jffs/scripts/init-start
Edit: Nevermind you said it works when run manually.

Or for another set of eyes, post the output of
Code:
ls -l /jffs/scripts
 
How did you create your init-start script? Using VI on the router or upload from a PC?

Try running
Code:
dos2unix /jffs/scripts/init-start
Edit: Nevermind you said it works when run manually.

Or for another set of eyes, post the output of
Code:
ls -l /jffs/scripts

dave@RT-AC86U-49E8:/jffs/scripts# ls -l
-rwxr-xr-x 1 dave root 191908 Sep 16 01:25 firewall
-rwxr-xr-x 1 dave root 101 Aug 9 11:27 firewall-start
-rwxr-xr-x 1 dave root 1460 Sep 7 13:39 firewall_watchdog.sh
-rwxr-xr-x 1 dave root 132 Sep 24 08:49 init-start
-rwxr-xr-x 1 dave root 70 Jul 31 10:21 post-mount
-rwxr-xr-x 1 dave root 69 Aug 9 11:27 services-stop
-rwxr-xr-x 1 dave root 117 Jul 31 10:21 unmount
 
Post the entire unedited contents of init-start. There be something in there that we're missing.
 
dave@RT-AC86U-49E8:/jffs/scripts# cat init-start
#!/bin/sh

logger "Dave crontab touched"
echo "*/5 * * * * sh /jffs/scripts/firewall_watchdog.sh" >> /var/spool/cron/crontabs/dave
 
Post the entire unedited contents of init-start. There be something in there that we're missing.

It was created with vi inside the router and runs fine when ran manually. The logger does not show up in syslog unless ran manually.
 
It was created with vi inside the router and runs fine when ran manually. The logger does not show up in syslog unless ran manually.
Are you running it manually as
Code:
/jffs/scripts/init-start
as the router would, or are you running it as
Code:
sh /jffs/scripts/init-start
Try the first variant if not already done.
 
Are you running it manually as
Code:
/jffs/scripts/init-start
as the router would, or are you running it as
Code:
sh /jffs/scripts/init-start
Try the first variant if not already done.

running it as
/jffs/scripts/init-start

worked fine.
 
Sorry @dvohwinkel I gave you bad advice. :oops: I should have double-checked.

init-start is too early in the boot process, you should be using services-start.

ahh I was starting to wonder that :) Thank you for checking. I will test it in a little bit.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Members online

Top