Find the answer to your Linux question:
Results 1 to 7 of 7
I want to execute a python script on my raspberrypi From a windows ssh client then close the client But let the script running on the pi. How should i ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2014
    Posts
    13

    Question Remote Executing python script


    I want to execute a python script on my raspberrypi
    From a windows ssh client then close the client
    But let the script running on the pi.

    How should i do that ?

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,048
    Code:
    nohup ./your_script &

  3. #3
    Just Joined!
    Join Date
    May 2014
    Posts
    13
    I tried it and it seems to work but when
    I close my client and reopen the connection

    the jobs cmd does not give anything

  4. #4
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,048
    I'm not familiar with the jobs command. To check on your script, presuming it's still running:
    Code:
    ps -ef | grep your_script

  5. #5
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    screen or tmux can be used.
    Both offer you to start sessions in which you can execute commands.
    You can then leave the session, disconnect from ssh and later reconnect to the tmux/screen session.

    These tools should be used for occasional and/or one-time jobs.
    If that python script is supposed to run much longer, then I would treat it as a daemon.
    Aka: write a init script, properly detach it, handle pid and logfile(rotation), etc
    You must always face the curtain with a bow.

  6. #6
    Just Joined!
    Join Date
    May 2014
    Posts
    13
    To explain further the script should run all day ,
    but since I have no keyboard connected to the pi
    i would like to start and stop it from another computer
    using ssh.

  7. #7
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    902
    I used to run scripts on remote machines with ssh it has the ability look at the -w option. I don't know if it will keeps the sesson open till the script finish my script was short so it didn't matter, but you can test it.
    A lion does not lose sleep, over the opinion of sheep.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •