Automated reminder service for backup

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

eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";

notify-send 'Hello Kuntal!' 'plug in your HDD and run backup process' --icon=dialog-information
exec echo weekly reminder Job ran at  `date` >> /var/log/weekly_reminder.log

That results to a nice reminder to me

Backup notification

Now I run the backup script to sync the required data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s