0

I have udev rules file to run a program on usb mount. I am running a bash script automount.sh when USB is connected to Pi.

#! /bin/sh

cd
cd /root
chmod 777 /media/USB
chmod 777 create_report.py
python3 create_report.py
umount

Bash script is running fine and executing the python program, but the program stops running when it executes MongoDB query instruction and no exception is raised. Attached basic version of python script below.

from pymongo import MongoClient

client = MongoClient()
current_col = client.current_db.current_c
data  = current_col.fins_one()  #Program stops here

Program is executing completely when executed this program manually.

4
  • As soon as Udev processing is complete it will kill (without prejudice) any program or script that has been spawned by any Udev rule.
    – Dougie
    Commented Oct 19, 2020 at 11:18
  • How to make the Udev process wait till program execution completes?
    – Prudhvi
    Commented Oct 22, 2020 at 4:25
  • You can't. You'll need to find a better way to get the process running and triggered from a udev event.
    – Dougie
    Commented Oct 22, 2020 at 23:11
  • I removed the MongoDB part from program, now the program completes execution even after adding delay in the program
    – Prudhvi
    Commented Oct 24, 2020 at 4:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.