Possible to run a cronjob when the "reboot" command is issued?

Is it possible to run a cronjob when the "reboot" command is issued?

That doesn't sound plausible. When you run the reboot command the system is going to a halt, so it won't start anything new. Maybe you could add the command you want in /etc/init.d/K01my_command and make a symlink to /etc/rc.d/

2 Likes

from https://man7.org/linux/man-pages/man5/crontab.5.html

EXTENSIONS top
These special time specification "nicknames" which replace the 5
initial time and date fields, and are prefixed with the '@'
character, are supported:

   @reboot    :    Run once after reboot.

IIRC, cron on OpenWrt behaves differently in that the @reboot is not available, but I might be wrong .

1 Like

I think @reboot is not available, but still from my understanding the OP needs the command to run when the command reboot is run and not when the reboot is done. For that there is rc.local.

2 Likes

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