Ubuntu – Execute Bash script at startup, but only once a day

bashcommand linescripts

I have a bash script that should be executed on ubuntu startup after boot.

The problem is the script should be only executed once a day.
So when the script recognizes that it already has been executed today it should stop itself. How can i do this?

Best Answer

As Ubuntu uses Anacron by default, you already have this behaviour by putting the script into /etc/cron.daily. Check run-parts --test /etc/cron.daily to check if your script is picked up (importantly, no .sh extension and the +x bit set). See this wiki page and man anacron for more detailed information about why this will work for you.

Related Question