Re: @reboot
- Reply: Jos Chrispijn : "Re: @reboot"
- In reply to: Jos Chrispijn : "@reboot"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 23 Oct 2021 15:45:10 UTC
Jos Chrispijn <bsduser@cloudzeeland.nl> writes: > I have created a script to be runned afte reboot of my server. > Thing is now that if I stop and start a service, the scripts is ran as well. > Is there a way of only executing after a total reboot? > I create a lock file in my @reboot script that checks to see if it is an actual reboot. I put it in the beginning of the script and just exit if it isn't a reboot, or create the lock file if it is a reboot. This is what I use: #--------------------- # lock to make sure it doesn't run again if [ ~/data/cron_lock -nt /var/run/boot_time ]; then exit 0 # already run fi mkdir -p ~/data touch ~/data/cron_lock #--------------------- I hope that helps. -- Carl Johnson carlj@peak.org