starting rsync from udev

General support questions
Post Reply
z.petersen1
Posts: 10
Joined: 2017/11/21 06:58:19

starting rsync from udev

Post by z.petersen1 » 2017/12/11 20:18:04

Hi,

I'm trying to start a Backup when I'm plugging in a USB Drive.
It works partially.
I'm starting the backupscript from the udev-rule.
But in the script when it start rsync.... after a few minutes it hangs and stopps working.
When I start the script by hand it works without any errors.
When I start the script from contab (e.g. /etc/cron.hourly) it works too.

what can be the reason?

greetings
-zoran-

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: starting rsync from udev

Post by pjsr2 » 2017/12/12 12:44:26

When you start a program from a udev rule, that program is supposed to complete within a short time, because udev waits for the completion of the program. Udev does not want to wait forever, since that would mean that it cannot handle other device events.

You should create a script that is called on insertion of your USB drive and that starts the rsync task as a (detached) background process, so the script can return promptly. See http://www.reactivated.net/writing_udev ... ternal-run

Post Reply