Can crontab use non-standard characters?

There are some versions of crontab that implement Seconds non-standard fields and “?” / “L” / “#” non-standard characters. Is the crontab of OpenWRT implemented?

1 Like
Cron in OpenWrt is provided by BusyBox.
BusyBox typically offers only the core features and strips off the extras.
It doesn't support seconds, but you can use sleep to adjust delay.
You can also use code comments.

1 Like

Restart at 23:59:30 on the last day of every month,

59 23 28-31 * * [ date -d tomorrow +\%e -eq 1 ] && sleep 30 && reboot

Is this correct?

You can easily verify that by setting up time a few minutes ahead and testing against the current date.

Ain’t it usually problematic to use cron for reboot since no RTC is available so when it wakes up again you start at the same time you had when the reboot was initiated and it gets in a reboot loop forever.

Why do you need a reboot once a month to begin with?

If that is the case that a reboot is to be made like this it is probably more quality assured to have a digital day timer in the wall socket that cuts power the day you want to reboot.

Not quite. You need to touch a file in /etc after waiting over a minute before reboot (in order to decrease the risk of that "reboot loop" mentioned by flygarn12).
Read this:

1 Like

Do you need a full reboot? A /etc/init.d/foobar restart on various services can help make them healthy again, flush memory usage, etc.


Thank you for reminding. Is the system time initialization based on the last modification time of the directories or files in the /etc directory? Can I create a new file myself?

The most recent file in /etc, any file (like said in the wiki link I gave above...)
The file can be created by you.

Relevant code:

(That is just a crude approximation to overcome the missing RTC. )

1 Like

Thank you !

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.