There is a task in the crown for example at 8.20. At this time, the computer is turned off. How to make, that when it turns on again, the task is executed?
|
2 answers
The idea is to add to the script (let's call it cronjob.sh) update some auxiliary file, for example, last
touch last Then add the same script to the autorun script as in cron and execute it if last was updated later than, for example, 1 hour ago
touch -d '-1 hour' referenceif [ reference -nt last ]; then # Выполнить скрипт из cron'а /home/user/cronjob.shfi The autorun script on different Linux is added differently, for example, for Ubuntu it is a string in the executable /etc/init.d/local
sudo echo "/home/user/autostart.sh" >> /etc/init.d/localsudo chmod +x /etc/init.d/localsudo update-rc.d local defaults 80 - Well, if you already have a cron - you can not touch all these rc.local, but use the @reboot directive in the cron file itself - bva
|
there is anacron https://ru.wikipedia.org/wiki/Anacron and other delayed launch commands.
|