I’m very much used to with cron jobs which are used frequently to schedule tasks. Cron can run as often as every minute. But it assumes that the system is running continuously and if the system is not up at the time when a job is scheduled, that job is not executed. I was in need of something like cron but the executing time must be dynamic. More specifically I had to run a backup reminder process in my local system automatically on a certain period frequency and only when the system is on.
So to achieve that I used anacron. Anacron does not expect the system to be running 24 x 7 like a server. Anacron is useful when a background job needs to be executed automatically on a machine that is not running all the time. The job is then executed as soon as the system is up.
Now the issue is default anacrontab only works for root user and I would like to use get my notification only when I log in using my specified user details; that notification should not come to other users. Anyway, setting up anacron instance for specific user is another context, that’s why I kept it in another post to describe how I achieved the same.
Code behind my reminder script which notifies me at every weekend.
#!/bin/bash notify-send 'Hello Kuntal!' 'plug in your HDD and run backup process' --icon=dialog-information echo weekly reminder Job ran at `date` >> /var/log/custom.log
That results to a nice reminder to me
Now I run the backup script to sync the required data.