receive notification when file arrives

Problem

You want to get notified when a file arrives. Maybe it is coming in from somewhere else, or just is the result of some processing.

What ever the case, never sit there waiting for a file to arrive again! 🙂



Solution

Put the code under example tab, in a cron entry. See reference for more detail about cron.

Change the minutes, hour, filename and mail address! 🙂 You may need to use mail instead of mailx and ksh, etc instead of bash. But the basic syntax is the same. 🙂



Example



0-59 12 * * * bash -c "([ -f $HOME/test-touch ] &&
mailx -s "test-touch found at `date`" [email protected]



Reference

[tags]cron, UNIX Batch, UNIX Scripts, Unix Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *