Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to run python ~/program/proxy.py in a terminal when I boot up. And then hide this terminal window (because it is just a proxy program, and I don't want to see the debug info). So how can I get it to work?

share|improve this question
    
As @andcoz notes, there is something wrong here. Running a python program as part of the boot process would not generate a terminal window in the first place. In fact even if it was part of the login/session script it shouldn't need a terminal window. Can you edit your question to show how exactly you have configured this NOW so it's more clear what needs to be changed to accomplish what you are after? –  Caleb Aug 1 '11 at 9:38

4 Answers 4

IMHO, the optimal solution is to run that proxy as system daemon.

This tutorial from Novel should teach you core concepts. Unluckily it is a little bit SuSE-centric, on other distributions the details could be slightly different. Use it as starting point.

P.S. There is something strange in your question, a service started at boot doesn't have a terminal window. A program started when you log on can have a terminal window. Perhaps do you have auto-login feature enabled, so you are confusing boot process with log-in process.

share|improve this answer

A more rough approach is to write a simple script that wraps your program and detaches it from its terminal. Something like:

#!/bin/bash

nohup python ~/program/proxy.py > ~/.proxy.log 2>&1 &

Then you can put it in your log-in auto-startup sequence (as you, probably, already done).

share|improve this answer
    
The posix nohup does not call setsid() (some implementations do) you've only isolated the signal, it's still in the same process group –  symcbean Aug 3 '11 at 15:56
    
Yes, @symcbean, you are right. Obviously, I prefer my other answer. This answer is only a quick and rough alternative. It also do not take in account that if you log out and then (re)log in, you'll run two instances of the proxy. –  andcoz Aug 3 '11 at 23:07
    
agreed writing a daemon would be a better approach, but 'echo /usr/bin/python ~/program/proxy.py | at now' is a quick fix. –  symcbean Aug 8 '11 at 20:04

Using tmux you can start a detached process, which is effectively "hidden", and attach it to check its status, as and when you like. If you start it from a terminal, you can even close that terminal session, and subsequently attach to your tmux python process from another terminal ...

This example uses watch as the command to run, but just substitute your python command... It starts the tmux session in an already deteched state.

tmux new -d 'watch -n 1 -d date'

To view the current state of the "hidden" (detached) session, just type tmux attach in a Terminal window...

You can also use screen, but I believe tmux may be the better choice, based on the comments in this Unix-&-Linux answer...

share|improve this answer

To provide you a literal answer to your question, you could use a program such as AllTray*. You could then pass it a command to start up a terminal, and pass a command to that terminal to run your program. If you tell AllTray to hide the terminal, then it will be embedded in the system tray, ready for you to pull up if you need to view the output.

However, I would recommend you go with andcoz's answer and run this program as a system dæmon. Have the output go to a log file. The only way that wouldn't work is if it were an interactive program, but by the sounds of it, we're not talking about an interactive program.

* Disclaimer: I am the maintainer of AllTray

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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