Is there any option to run a task when specific event occurs (i.e. Flash Drive inserted), but to do it just once a month?
I am trying to hook my backup script on some auto event..
OS: Windows 7 x64 Professional
Do you have experience with WMI (Windows Management Instrumentation)? It's perfect for this kind of tasks. Also, it's a part of Windows so it should cause minimal overhead.
Below is an example of a Perl script that executes some simple actions when a USB drive is plugged in. Your script doesn't have to be in Perl, WMI supports a whole range of scripting and programming languages.
Register event (usb plugged in)
Link event and action
This is a form of permanent event registration. To disable and clean the entire process up, remove the created objects:
You can search for the objects using WMI CIM Studio. Downloadable from Microsoft for free, here.
Have the script :
That way you can also know when the last full backup occured (look at /etc/last_backup)
A way do know if file exist and is LESS than 30 days:
and immediately after, $? will be "0" if grep could find it
That way, to force backup, just remove the /etc/last_backup file and next time the script will start the backup.
I suggest Task Scheduler would be a simpler idea. However, success depends on finding a trigger to the event, and for that I would look in the Event logs.
My thinking is to master the backup command, save in a script, then use the power of the Task Scheduler service to handle the timing.