Hello,
I have a python script which runs all the time (using of library
threading). I would like this scipt to run on a remote linux Os using
Putty. The problem is, when I close Putty command line window running
on my Win PC, the python script stops to run too.
I tried to use cron tables instead. By setting the time and restart
cron process, but it's not practical.
Do you know the right way to do this ?
Regards 8 8814
Ulysse wrote:
Hello,
I have a python script which runs all the time (using of library
threading). I would like this scipt to run on a remote linux Os using
Putty. The problem is, when I close Putty command line window running
on my Win PC, the python script stops to run too.
I tried to use cron tables instead. By setting the time and restart
cron process, but it's not practical.
Do you know the right way to do this ?
There are a few ways to do this, in order of easiest to most involved:
1. The easiest is to run nohup on your script in the background:
$ nohup myscript.py output.txt 2error.txt &
Then you can disconnect but your script will keep running. Try man nohup
for more information.
2. Use GNU screen on your remote terminal, and detach the screen instead
of logging off.
3. Set up your script to fork as a daemon. Google for ["python cookbook"
fork daemon] to find a few recipes for this.
--
Michael Hoffman
On Apr 2, 12:56 am, Michael Hoffman <cam.ac...@mh39 1.invalidwrote:
Ulysse wrote:
Hello,
I have a python script which runs all the time (using of library
threading). I would like this scipt to run on a remote linux Os using
Putty. The problem is, when I close Putty command line window running
on my Win PC, the python script stops to run too.
I tried to use cron tables instead. By setting the time and restart
cron process, but it's not practical.
Do you know the right way to do this ?
There are a few ways to do this, in order of easiest to most involved:
1. The easiest is to run nohup on your script in the background:
$ nohup myscript.py output.txt 2error.txt &
Then you can disconnect but your script will keep running. Try man nohup
for more information.
2. Use GNU screen on your remote terminal, and detach the screen instead
of logging off.
3. Set up your script to fork as a daemon. Google for ["python cookbook"
fork daemon] to find a few recipes for this.
--
Michael Hoffman
Thanks a lot but in my situation :
1. nohup seems not to be installed on my "reduced linux distribution".
It's a OpenWrt tunning on my WRT54GL Broadband router.
2. I have looked for the way I can "detach the screen" with Putty but
I've not found (May be you can precise ?)
3. The "fork daemon" script found on http://aspn.activestate.com/ASPN/Coo.../Recipe/278731
seems to be as huge as my own script and little bit hard to undestand.
So maybe "detach the screen" ?
Thanks
On Apr 2, 1:51 pm, "Ulysse" <maxim...@gmail .comwrote:
On Apr 2, 12:56 am, Michael Hoffman <cam.ac...@mh39 1.invalidwrote:
Ulysse wrote:
Hello,
I have a python script which runs all the time (using of library
threading). I would like this scipt to run on a remote linux Os using
Putty. The problem is, when I close Putty command line window running
on my Win PC, the python script stops to run too.
I tried to use cron tables instead. By setting the time and restart
cron process, but it's not practical.
Do you know the right way to do this ?
There are a few ways to do this, in order of easiest to most involved:
1. The easiest is to run nohup on your script in the background:
$ nohup myscript.py output.txt 2error.txt &
Then you can disconnect but your script will keep running. Try man nohup
for more information.
2. Use GNU screen on your remote terminal, and detach the screen instead
of logging off.
3. Set up your script to fork as a daemon. Google for ["python cookbook"
fork daemon] to find a few recipes for this.
--
Michael Hoffman
Thanks a lot but in my situation :
1. nohup seems not to be installed on my "reduced linux distribution".
It's a OpenWrt tunning on my WRT54GL Broadband router.
2. I have looked for the way I can "detach the screen" with Putty but
I've not found (May be you can precise ?)
3. The "fork daemon" script found onhttp://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/278731
seems to be as huge as my own script and little bit hard to undestand.
So maybe "detach the screen" ?
Thanks
Try running the script with the ampersand (&) at the end.
../myscript.py &
that will put it in the background and you can exit the Putty window.
You can start the script at boot by adding it to rc.local using the
full path to the script.
/path/to/myscript.py &
On Apr 2, 2:07 pm, "ihccab" <ihc...@gmail.c omwrote:
On Apr 2, 1:51 pm, "Ulysse" <maxim...@gmail .comwrote:
On Apr 2, 12:56 am, Michael Hoffman <cam.ac...@mh39 1.invalidwrote:
Ulysse wrote:
Hello,
I have a python script which runs all the time (using of library
threading). I would like this scipt to run on a remote linux Os using
Putty. The problem is, when I close Putty command line window running
on my Win PC, the python script stops to run too.
I tried to use cron tables instead. By setting the time and restart
cron process, but it's not practical.
Do you know the right way to do this ?
There are a few ways to do this, in order of easiest to most involved:
1. The easiest is to run nohup on your script in the background:
$ nohup myscript.py output.txt 2error.txt &
Then you can disconnect but your script will keep running. Try man nohup
for more information.
2. Use GNU screen on your remote terminal, and detach the screen instead
of logging off.
3. Set up your script to fork as a daemon. Google for ["python cookbook"
fork daemon] to find a few recipes for this.
--
Michael Hoffman
Thanks a lot but in my situation :
1. nohup seems not to be installed on my "reduced linux distribution".
It's a OpenWrt tunning on my WRT54GL Broadband router.
2. I have looked for the way I can "detach the screen" with Putty but
I've not found (May be you can precise ?)
3. The "fork daemon" script found onhttp://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/278731
seems to be as huge as my own script and little bit hard to undestand.
So maybe "detach the screen" ?
Thanks
Try running the script with the ampersand (&) at the end.
./myscript.py &
that will put it in the background and you can exit the Putty window.
You can start the script at boot by adding it to rc.local using the
full path to the script.
/path/to/myscript.py &
To check that is is running in the background, do:
ps -ef | grep myscript.py
You will see the process table entry for your script with the PID and
other info.
[Michael Hoffman]
>1. The easiest is to run nohup on your script in the background:
$ nohup myscript.py output.txt 2error.txt &
Then you can disconnect but your script will keep running. Try man nohup for more information.
2. Use GNU screen on your remote terminal, and detach the screen instead of logging off.
3. Set up your script to fork as a daemon. Google for ["python cookbook" fork daemon] to find a few recipes for this.
[Ulysse]
1. nohup seems not to be installed on my "reduced linux distribution".
It's a OpenWrt tunning on my WRT54GL Broadband router.
If you are running bash, you can do this:
$ myscript.py &
[1] 30834
$ disown %1
2. I have looked for the way I can "detach the screen" with Putty but
I've not found (May be you can precise ?)
Google for GNU screen. But it probably won't be installed either, if
nohup isn't.
3. The "fork daemon" script found on http://aspn.activestate.com/ASPN/Coo.../Recipe/278731
seems to be as huge as my own script and little bit hard to undestand.
OK, another alternative is to simulate nohup yourself, using the signal
module. You might want to read the docs and search the cookbook for
examples of its use. I think it would be something like:
import signal
signal.signal(s ignal.SIGHUP, signal.SIG_IGN)
--
Michael Hoffman
On 2007-04-02, Michael Hoffman <ca*******@mh39 1.invalidwrote:
>>1. The easiest is to run nohup on your script in the background:
$ nohup myscript.py output.txt 2error.txt &
Then you can disconnect but your script will keep running. Try man nohup for more information.
2. Use GNU screen on your remote terminal, and detach the screen instead of logging off.
3. Set up your script to fork as a daemon. Google for ["python cookbook" fork daemon] to find a few recipes for this.
[Ulysse]
>1. nohup seems not to be installed on my "reduced linux distribution". It's a OpenWrt tunning on my WRT54GL Broadband router.
If you are running bash, you can do this:
He's not running bash. He's running busybox's shell.
[He'd be far better off asking his question in an OpenWRT or
Busybox forum, since it's got absolutely nothing to do with
Python.]
--
Grant Edwards grante Yow! They don't hire
at PERSONAL PINHEADS,
visi.com Mr. Toad!
[Michael Hoffman]
>If you are running bash, you can do this:
[Grant Edwards]
He's not running bash. He's running busybox's shell.
There's a nohup applet for busybox.
[He'd be far better off asking his question in an OpenWRT or
Busybox forum, since it's got absolutely nothing to do with
Python.]
I was going to say that originally, but then I realized that the daemon
solution is on-topic. So is masking SIGHUP.
--
Michael Hoffman
On Apr 2, 8:54 pm, Michael Hoffman <cam.ac...@mh39 1.invalidwrote:
[Michael Hoffman]
If you are running bash, you can do this:
[Grant Edwards]
He's not running bash. He's running busybox's shell.
There's a nohup applet for busybox.
[He'd be far better off asking his question in an OpenWRT or
Busybox forum, since it's got absolutely nothing to do with
Python.]
I was going to say that originally, but then I realized that the daemon
solution is on-topic. So is masking SIGHUP.
--
Michael Hoffman
Actually the "./myscript.py &" command seems to work well. I can close
the Putty console, and then after logging the command "top" show me
that my process is still running. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob Bedford |
last post by:
I've a script that must "launch" an other script on some situations.
firstscript.php:
....
If ($newarticle)
//launch secondscript.php
....
The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
|
by: Dan V. |
last post by:
Situation:
I have to connect with my Windows 2000 server using VS.NET 2003 and C# and
connect to a remote Linux server at another company's office and query their
XML file. Their file may be updated every hour or so. How can I do this
easily? I would like to use secure communication even encryption if
possible. I would query and insert locally only the newest records found in
that XML file to an xml or MS access db.
|
by: Harlin Seritt |
last post by:
I have a remote linux server where I can only access it via ssh. I have
a script that I need to have run all the time. I run like so:
python script.py &
It runs fine. When I log off ssh I notice that the script died when I
logged off. How do I make sure it stays running?
thanks,
|
by: kinane3 |
last post by:
I'm been using dev environments like Dreamweaver with ASP for years
and recently got a php job that requires SSH to access the server.
Command line is really new to me and I need to learn this. Also I
can't seem to find a way to access the server with Dreamweaver MX 2004.
The guys there say it's not possible but no one there really knows
Dreamweaver that well. Is there a way they/I don't know of?
Thanks!
|
by: shybe |
last post by:
Ok,
Im trying to create a "send this article to a friend" script for my
blog,
Right now its sending all the articles,
but I want it to only send the article in which the form is attached
to.
| |
by: aha |
last post by:
Hello All,
I have a situation where I can count on a Python installation being
available on a system, but I can't count on it being a version of
Python needed by my application. Since my application has it's own
version of Python installed with it how should I use the system Python
to launch the version of Python that launches my Application. Yes,
this is a convoluted process, but not all Pythons are built the
same :)
Right now I am...
|
by: jwwicks |
last post by:
C/C++ Programs and Debugging in Linux
This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use some of the tools provided on the command-line. If you hate the command line tools, get over it since you’re bound to be using them at some point in your career. All commands in Linux ARE case sensitive so capital letters are different from lowercase...
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke this shell script using the
Subprocess module. Here is my code:
def resultFromRunning_(command):
|
by: macca |
last post by:
Hi,
I just started a new web developer job (my first actually) and the
machine they gave me to use is a Mac. Two days in and I'm running a
Win XP environment on my Mac at work (using VMWare), firstly so I can
use my favourite text editor (ConTEXT) which is only available for
windows and secondly because I've never used a Mac before.
But what do you think is the best all round development platform that
I should use as a Web Developer?...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |