Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

UDEV Rule starts Backupskript, programs not running

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Alebo
Posts: 2
Joined: 2018-03-26 18:01

UDEV Rule starts Backupskript, programs not running

#1 Post by Alebo »

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)

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: UDEV Rule starts Backupskript, programs not running

#2 Post by Dai_trying »

Might help if you post your udev rule in case there is an error...

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: UDEV Rule starts Backupskript, programs not running

#3 Post by Head_on_a_Stick »

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.
deadbang

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 12 times
Been thanked: 66 times

Re: UDEV Rule starts Backupskript, programs not running

#4 Post by dilberts_left_nut »

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
ralph.ronnquist
Posts: 342
Joined: 2015-12-19 01:07
Location: Melbourne, Australia
Been thanked: 6 times

Re: UDEV Rule starts Backupskript, programs not running

#5 Post by ralph.ronnquist »

At a guess, udevd has PATH=/sbin:/bin and your script wants to run programs residing in /usr/bin.

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1388
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 65 times

Re: UDEV Rule starts Backupskript, programs not running

#6 Post by None1975 »

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 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

Alebo
Posts: 2
Joined: 2018-03-26 18:01

Re: UDEV Rule starts Backupskript, programs not running

#7 Post by Alebo »

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.

Post Reply