UDEV Rule starts Backupskript, programs not running

Need help with C, C++, perl, python, etc?

UDEV Rule starts Backupskript, programs not running

Postby Alebo » 2018-03-26 18:35

Hello,

I try to write a skript wihch starts by a udev rule if I plug in a usb-hdd.
That rule works, because the skript write the date in a log file
Code: Select all
 echo "$(date) Backup" >>/root/backup.log;

But no programs run if this skript starts over the udev rule.
If I start the skript at the terminal all programms are running. (rdiff-backup, firefox......)

Any Ideas?

I use Debian GNU/Linux 9.3 (stretch)
Alebo
 
Posts: 2
Joined: 2018-03-26 18:01

Re: UDEV Rule starts Backupskript, programs not running

Postby Dai_trying » 2018-03-26 18:44

Might help if you post your udev rule in case there is an error...
Dai_trying
 
Posts: 567
Joined: 2016-01-07 12:25

Re: UDEV Rule starts Backupskript, programs not running

Postby Head_on_a_Stick » 2018-03-26 18:47

You should probably post the script itself and the udev rule along with an explanation of what you are actually trying to acheive (just in case there is a better method) but this thread seems to indicate that the location of the script might be important:

https://superuser.com/questions/305723/ ... -insertion

Note that udev rules are not intended to start long-running processes.
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: UDEV Rule starts Backupskript, programs not running

Postby dilberts_left_nut » 2018-03-26 19:37

Head_on_a_Stick wrote:Note that udev rules are not intended to start long-running processes.

Probably this ^^

You can call a wrapper script from your udev rule that forks the actual process then dies.
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 4914
Joined: 2009-10-05 07:54
Location: enzed

Re: UDEV Rule starts Backupskript, programs not running

Postby ralph.ronnquist » 2018-03-26 22:42

At a guess, udevd has PATH=/sbin:/bin and your script wants to run programs residing in /usr/bin.
User avatar
ralph.ronnquist
 
Posts: 315
Joined: 2015-12-19 01:07
Location: Melbourne, Australia

Re: UDEV Rule starts Backupskript, programs not running

Postby None1975 » 2018-03-27 13:25

Alebo wrote:Hello,I try to write a skript wihch starts by a udev rule if I plug in a usb-hdd.

Why not simply use the udevil?
OS: Debian Stretch / WM: Fluxbox
Debian Wiki | DontBreakDebian, My config files in github
User avatar
None1975
 
Posts: 705
Joined: 2015-11-29 18:23
Location: Lithuania, Vilnius

Re: UDEV Rule starts Backupskript, programs not running

Postby Alebo » 2018-03-27 18:23

Hello,

many Thanks to all for your answers

I found this in Manpage Udev (same as dilberts_left_nut wrote):
Code: Select all
 RUN{type}
 This can only be used for very short-running foreground tasks. Running an event process for a long period of time may block all further
           events for this or a dependent device.

           Starting daemons or other long-running processes is not appropriate for udev; the forked processes, detached or not, will be
           unconditionally killed after the event handling has finished.


So I will put
Code: Select all
ENV{SYSTEMD_WANTS}="device-attach.service"
instead of
Run+=....


in my udev rule and start the skript with this service.
Alebo
 
Posts: 2
Joined: 2018-03-26 18:01


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable