Fehérke's GitHub Site == glue between Fehérke's GitHub hosted projects

onceaday.sh - run commands only once a day

The utility of this script is disputable, but I decided to publish it, just because I like it. Because I like working with text files and the crontab-like time patterns always fascinated me.

Simply I wanted something to show me some reminders, notices, anything when I start to work at my computer. In my case, this mean, when I open the first interactive shell. So the best method is to put it in the shell’s personal initialization file and save the last run’s timestamp somewhere in a file. But this would be boring simple, so I added timestamp conditions to the configuration file.

onceaday.sh by default does not print anything to not mess up the output of the run commands. The below output was obtained with the -a -s parameters on January 1st :

sample output - onceaday.sh -a -s

fortune
cat /home/master/holiday-warning.txt

The initial idea was to make it functional even by sourcing it or run properly. But I realized, that sourced files loose their identity, and can not find out their name and path, so can get its configuration file. So I renounced to this idea. Anyway, if I will find a bulletproof solution without using hardcoded reference points, probably I will rewrite this script.

Configuration

onceaday.ini looks like a usual crontab file, with the usual 5 time fields and 1 command. With one twist : while in traditional crontab there is an or operation between the day of month and day of week checks, in onceaday.ini there are and operations between all checks.

The time can be specified as ( examples expanded as in case of month ) :

For more see the sample onceaday.ini provided with the script.

The command can be :

onceaday.ini - sample configuration

* * * * * fortune
* * 1,2 1 * ~/holiday-warning.txt
* * 14 2 * figlet I hate this day

Versions

Plans

Download

You can find the related files on GitHub in my bash-script repository’s onceaday directory :