0

I am launching a script with a udev rules on every usb device connection. The issue is than i need than this script to launch another one after 20 seconds.

This is the code.

#!/bin/bash
#
sleep 20
/'Another Script'

The problem is than doing like this with delay the udev mount operation, what i do not want to happen.

Have tried this:

#!/bin/bash
#
nohup bash /'Other Script' & 
fg

Putting the waiting inside the 'Other Script'.

SOLVED

The udev rule was launched with RUN{type}, that was the problem, it cannot handle long process, i just create a systemd service and lauch it using ENV{SYSTEMD_WANTS} on the udev rules and like silk.

Do this:

/etc/udev/rules.d/99-usb.rules

    ACTION=="add", ENV{SYSTEMD_WANTS}="usb.service"

/etc/systemd/system/usb.service

    [Unit]
    Description=USB Autorun.
[Service]
Type=oneshot
ExecStart=/Script.sh

/Script.sh

    #!/bin/bash
    #
    sleep 20
    /'Another Script'

0 Answers0