0

I launch below process with & so as to keep it running in background after I close session :

pi@raspberrypi2 ~ $ ./spark-1.3.0-bin-hadoop2.4/bin/spark-class org.apache.spark.deploy.worker.Worker -m 700M spark://192.168.192.22:7077 &
[1] 3538
pi@raspberrypi2 ~ $ Spark assembly has been built with Hive, including Datanucleus jars on classpath
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
15/04/04 19:35:47 INFO Worker: Registered signal handlers for [TERM, HUP, INT]
15/04/04 19:35:47 WARN Utils: Your hostname, raspberrypi2 resolves to a loopback address: 127.0.1.1; using 192.168.192.55 instead (on interface eth0)
15/04/04 19:35:47 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
^C
pi@raspberrypi2 ~ $ 15/04/04 19:35:51 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

But as can see, the output is just temporarily hidden from view and when I close session the process stops.

How to launch process on Raspbian and keep it running after I have closed PI session ?

I have tried installing screen but I'm unable to switch screens when content is logged to output ?

  • Look at the nohup command. – joan Apr 4 '15 at 20:00
2

This is actually a Linux general question as opposed to Pi specific ... but the answer is to use the nohup command. Read about it here:

http://linux.die.net/man/1/nohup

Basically run:

$ nohup <your command and parameters go here> &

Nohup traps the hangup signal which is sent when you disconnect your screen/terminal from the process.

  • 1
    It is a general linux Q but if someone here has a decent quick answer, cool (+1). I'd recommend setsid over nohup but if the latter works don't worry. – goldilocks Apr 4 '15 at 22:32
  • tmux is another option. – tarabyte Apr 6 '15 at 2:42
  • I prefer nohup as it's with raspbian by default, tmux isn't installed – Aidan Connelly Jun 29 '18 at 8:31
0

What do you mean you are unable to switch screens? Usually you start screen, run the program, disconnect with Ctrl+a d then close ssh. Then open ssh later and check on the program with screen -r or screen -ls if more than one is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.