I have a backup script which requires user interaction. I would like to schedule it to run, say, once a week.
The constraints are that (1) the computer boots straight into Gnome and is turned off daily, (2) the user must be able to opt out of running the script and see any script output on the screen.
I understand that Gnome Scheduler uses anacron
for weekly cron jobs, and that missed jobs are run on startup. But that's no use if the job requires a terminal window for user confirmation, because the script will run before Gnome starts.
Gnome, of course, has Startup Applications, for programs to be run on startup. But that's only so helpful, since I don't want my script running at every startup.
A solution?
Based partly on feedback in the comments, here is the solution I came up with.
1. Create an empty logfile,
~/.lastbackup.log
, to contain a record of the time the backup script last ran.2. Create a wrapping scheduler script,
~/scheduler.sh
, to be placed in Gnome's Startup Applications (~/.config/autostart
), to check the logfile date at each boot and decide whether to run the main script:3. Create the main backup script,
~/backup.sh
, to run when necessary: