Date: Sat, 23 Oct 2021 08:45:10 -0700 From: Carl Johnson <carlj@peak.org> To: freebsd-questions@freebsd.org Subject: Re: @reboot Message-ID: <861r4bagop.fsf@bay.localnet> In-Reply-To: <224ff1f8-8ad2-3e5c-f7ed-17805c073ada@cloudzeeland.nl> (Jos Chrispijn's message of "Sat, 23 Oct 2021 16:09:33 %2B0200") References: <224ff1f8-8ad2-3e5c-f7ed-17805c073ada@cloudzeeland.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?861r4bagop.fsf>
