[CentOS] Triggering script from cron or web client

Sun Jul 10 05:22:54 UTC 2011
Emmanuel Noobadmin <centos.admin at gmail.com>

On 7/9/11, Kenneth Porter <shiva at sewingwitch.com> wrote:
> I have a Bash script, currently run a couple times an hour from cron, that
> pulls data from an old Windows DB by rsync, converts it to SQL, and injects
> it into a MySQL DB for display in a LAMP-based app. (Make and Perl are also
> involved to minimize the number of tables touched and to clean up the SQL
> generated by Pxlib.)
>
> I'd like to add the ability to refresh the data immediately from the web
> app, but I don't want it to trample on the periodic script and corrupt the
> data.

Offhand, I think checking for a lock file before starting is probably
the easiest way to do it. That's what I do for scripts that are
cronjobs but can also be initiated manually. However, this might not
work if your web app is inserting/updating the data in MySQL directly
rather than simply starting a new import process as I'm assuming.