Scheduling jobs in UNIX without cron —21 July 2014
If you happen to be unfortunate enough to be in a system where you’re not allowed to use
you might be able to do something similar with
Here’s a script that reschedules itself to run the next day at 8:45am:
#!/bin/bash the_main_thing &>/dev/null [[ $0 = /* ]] && script=$0 || script=$PWD/$0 at -f "$script" 0845 &>/dev/null
the_main_thing is the command or script you want to run periodically.
The purpose of
[[ $0 = /* ]] && script=$0 || script=$PWD/$0 is to get the absolute path of the current script itself.
at -f "$script" 0845 &>/dev/null,
-f is to specify the script to run:
the current script itself with absolute path,
otherwise it might not work.
To run something every 5 hours, you can use relative times, for example:
at -f "$script" 'now + 5 hours' &>/dev/null
the output of scheduled
at jobs is emailed to the UNIX account.
To prevent polluting the mailbox,
it’s probably a good idea to redirect both with
and you might want to do the same for
To view your scheduled tasks, use
To remove scheduled tasks, use