Running a python script in the background in init.d

to interact with my iPhone, I created a python script that sends and returns data via a socket, the script must be run after emule to work, I thought of something like this:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/amuled
WEB=/usr/local/bin/amuleweb
NAME=amuled
DESC=amuled
RUNAMULE=no
USER=piros
# ADDED FOR iPhone
SOCKET= /home/piros/amule_scripts/aMuleSocket/aMuleSocket.py
#

And then

case "$1" in
start)
  echo -n "Starting $DESC: "
   su $USER -c "$DAEMON -f"
   while ! netstat -l -n -p -t | grep -q amuled ; do sleep 1 ; done
   su $USER -c "$WEB --quiet & "
   ##iPhone
   su $USER -c "$SOCKET & "
   ##
echo "$NAME."
;;

The big problem is that although I have indicated and will sign that the process does not want to run in the background :( any ideas

Thank!

+3
source share
2 answers

Put the process suin the background, not in its child. For example:

su $USER -c "$WEB --quiet" &

Note that the ampersand is out of quotation marks.

+4
source

try running with nohup process.py &

+2
source

Source: https://habr.com/ru/post/1727374/


All Articles