debian - Bash script to check if running -


i have following in crontab sync folders on servers run on round robin dns settings syncs every minute.

* * * * * rsync -ar --delete -e ssh user@skynet.rizzler.se:/home/user/folder1/ /home/user/folder1/ >/dev/null 2>&1 * * * * * rsync -ar --delete -e ssh user@skynet.rizzler.se:/home/user/folder2/ /home/user/folder2/ >/dev/null 2>&1 

this rsync works small files, it's getting bigger wondering how can script, put script crontab , each time script run, check if it's running. if script running, nothing; if it's not running, should go ahead , start rsync.

anyone know how can this?

as swornabsent noted in comments, can use file-based locks, though link identifies reasons not use it. see this question quick-and-dirty locking in shell scripts, has great answer advantages directory-based locks instead.

to identify whether process running, may choose use pgrep, though may not idea in general case due time after check , before process starts up.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -