Skip to content

rsync nur einmal starten

Ab und an dauert ein rsync Job länger als geplant. Wenn man sicherstellen möchte, dass rsync in einem Cronjob nur ausgeführt wird, falls es nicht schon läuft, kann man folgendes Konstrukt verwenden:

pgrep -c rsync || rsync [options] quelle ziel

Ich hatte das vor einiger Zeit bei Serverfault schon mal als Antwort eingestellt, aber eigentlich ist es in meinem Blog auch gut aufgehoben. 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Felix on :

Ich arbeite inzwischen sehr gerne mit einem "Lockdir", da mkdir und rmdir hat ultraportabel sind.
  1.  
  2. if mkdir $LOCKDIR; then
  3.         echo "Locking succeeded"
  4.         ...
  5.         rmdir $LOCKDIR && echo "Locking removed"
  6. else
  7.         echo "Lock failed - exit"
  8.         exit 1
  9. fi
  10.  

Hat auch den Vorteil, dass weiterhin andere rsync Prozesse laufen könnten.

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
BBCode format allowed
You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Form options
tweetbackcheck cronjob