Make app run in background?

Questions and Answers : Unix/Linux : Make app run in background?
Message board moderation

To post messages, you must log in.

AuthorMessage
Chris Wilcox

Send message
Joined: 3 Apr 99
Posts: 1
Credit: 525
RAC: 0
United Kingdom
Message 711 - Posted: 23 Jun 2004, 17:13:59 UTC

Hi,

Is there anyway I can start the app so it runs in the background? I have an annoying habit of closing terminals without thinking what apps are running in them!

Regards,

Chris
ID: 711 · Report as offensive
Darren
Volunteer tester
Avatar

Send message
Joined: 2 Jul 99
Posts: 259
Credit: 280,503
RAC: 0
United States
Message 792 - Posted: 23 Jun 2004, 20:56:02 UTC

I assume you're talking about a terminal you've opened within a gui. I do the same thing occassionally. I'm sure there are many better ways to get around this, but I just change to an available tty (alt-ctrl-F#) and start the client there, that way whatever I do in the gui (even logging out) doesn't stop boinc. Pick any F# except F7 - that's where your gui runs - then just alt-ctrl-F7 to get back to your gui after you've started the client elsewhere.


ID: 792 · Report as offensive
Merlin
Volunteer tester

Send message
Joined: 24 Nov 99
Posts: 18
Credit: 4,168,479
RAC: 1
Germany
Message 806 - Posted: 23 Jun 2004, 21:10:52 UTC

You can run an application (such as boinc) in background like this:

Open an terminal and type

./boinc_xxx > logfile.txt 2>&1 &

This starts boinc in background and redirects output to a logfile (logfile.txt). You can now exit this terminal with CTRL + D
ID: 806 · Report as offensive
Mark Bauer

Send message
Joined: 3 Apr 99
Posts: 3
Credit: 1,748,491
RAC: 0
United States
Message 1186 - Posted: 24 Jun 2004, 14:35:58 UTC

You might also try the screen command. It works well for me.

mark

ID: 1186 · Report as offensive
jkmobrien

Send message
Joined: 8 Dec 00
Posts: 7
Credit: 260,674
RAC: 0
Ireland
Message 1773 - Posted: 25 Jun 2004, 8:19:54 UTC

When you start it, you can use nohup and the background operator...

nohup boinc_xxx &

That way closing the window, or logging out, won't kill the process.

John
ID: 1773 · Report as offensive
Profile Trane Francks

Send message
Joined: 18 Jun 99
Posts: 221
Credit: 122,319
RAC: 0
Japan
Message 3364 - Posted: 2 Jul 2004, 5:12:19 UTC

You should be able to run this as a cron job, e.g.,

$ crontab -e
0 1,5,9,13,17,21 * * * cd /home/trane/boinc/ ; ./boinc_3.18_i686-pc-linux-gnu > /dev/null 2> /dev/null

Save your job with :wq to exit the editor. Basically, this is the same method used to run the classic seti@home. You can look at the slot's state.sah task to monitor progress. An instance should give you a load of 1.0 for each CPU running.

trane

ID: 3364 · Report as offensive
S@NL - rob

Send message
Joined: 2 Oct 99
Posts: 10
Credit: 124,589
RAC: 0
Netherlands
Message 8816 - Posted: 16 Jul 2004, 19:47:22 UTC

i found on this page 2 ways to run it on the bachground.

http://predictor.scripps.edu/client.php#cmdline

i found these 2 ways

How can I install my BOINC client as a background process which always runs even if I log out of my PC

and

How can I install my BOINC client so that it is automatically started when I boot my PC

rob
ID: 8816 · Report as offensive
Profile repi

Send message
Joined: 29 Oct 00
Posts: 5
Credit: 194,630
RAC: 0
Germany
Message 14773 - Posted: 8 Aug 2004, 16:32:43 UTC

start boinc hide on console 9

#! /bin/sh
cd /home/boinc
nice -1 /home/boinc/boinc &>/dev/tty9 &

start boinc foreground with option to upgrade

#! /bin/sh

if [ $1 ]; then
cd /home/boinc
nice -1 /home/boinc/boinc -update_prefs http://setiathome.berkeley.edu
else
nice -1 /home/boinc/boinc
fi

stop boinc

#! /bin/sh
pid=$(ps -aux |grep boinc |grep -v grep |awk '{print $2}')
eval kill $pid


the boincclient must named boinc

SuSE Linux you can open the startscript in the boot.local
ID: 14773 · Report as offensive
not in use

Send message
Joined: 22 Jun 01
Posts: 32
Credit: 1,554
RAC: 0
United Kingdom
Message 14779 - Posted: 8 Aug 2004, 17:08:43 UTC

If you are using KDE as a desktop. I think the best way
with my setup was.

1. Write a simple script

#!/bin/sh
cd /home/user/bin/boinc
exec /home/user/bin/boinc/boinc_3.20_i686-pc-linux-gnu

2. Creat a short cut in to the script
/home/user/.kde/Autostart


Whare user is replace with correct name. And with point one chage the
directory name after cd and exec. I did not want projects running as root.
You should have one instance of Boinc running every time you loggin.
ID: 14779 · Report as offensive
Profile Yavin

Send message
Joined: 15 Jul 04
Posts: 3
Credit: 19,749
RAC: 0
Germany
Message 16568 - Posted: 23 Aug 2004, 10:36:15 UTC

I think screen is the best way to push a app to the background. If you use the a console you won't have acces through a remote connection to the appa output. Screen also doesn't care if your're logged in or not. Everytime you come back you can pop the app back with screen -r. The screens made by screen are interactive so it's possible to interact with the app.
-[may the force be with you]=-
ID: 16568 · Report as offensive
Jaguar

Send message
Joined: 4 Jan 04
Posts: 1
Credit: 1,171,537
RAC: 0
Canada
Message 20270 - Posted: 31 Aug 2004, 5:36:47 UTC

As jkmobrien stated you can use nohup, works great. I use the following:

nohup ./boinc_xxxxxx > log.txt &






ID: 20270 · Report as offensive
Profile Jean-Pierre Godet

Send message
Joined: 12 Sep 99
Posts: 4
Credit: 41,648
RAC: 0
France
Message 40929 - Posted: 28 Oct 2004, 9:54:25 UTC
Last modified: 26 Nov 2004, 15:06:22 UTC

The way I use to run BOINC as a background task on a Linux machine
automatically at startup :
1) a small shell script is used to prepare running the programm as a
background task ;
2) The /etc/inittab file is modified by adding a line which is
calling the shell script at startup and is creating a new virtual console that
displays SETI@home working.

An exemple : here, boinc (boinc_4.09_i686-pc-linux-gnu) is located in the
/home/godetj/files/SETI directory. In the same directory is located the small
shell script "startboinc".

Content of the startboinc executable file :
------------------------------------------------------------------
#!/bin/sh
cd /home/godetj/files/SETI
rm -f ./lockfile
exec ./boinc_4.09_i686-pc-linux-gnu < $1 > $1 2>&1
------------------------------------------------------------------

and a 7th virtual concole is added to the /etc/inittab like that :

Part of the inittab file showing the new line added :
------------------------------------------------------------------
# These are the standard console login getties in multiuser mode:
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:1235:respawn:/sbin/agetty 38400 tty3 linux
c4:1235:respawn:/sbin/agetty 38400 tty4 linux
c5:1235:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux

c7:12345:respawn:/home/godetj/files/SETI/startboinc /dev/tty7
------------------------------------------------------------------

Best regards !

--
Jean-Pierre - Powered by Linux (Slackware 10.0 - kernel 2.4.26)

ID: 40929 · Report as offensive
Joseph

Send message
Joined: 28 Mar 02
Posts: 1
Credit: 2,646,679
RAC: 1
United States
Message 46615 - Posted: 15 Nov 2004, 4:39:29 UTC

Here's the simplest solution:

[josephp@localhost seti]$./boinc_4.09_i686-pc-linux-gnu &

Seti will display some text, blah blah, press return, now you're at a prompt. Logout. When you log back in, do a ps -ax and you'll see Boinc and Seti running. It runs in the background. No need for no complicated scripts ;-)

Of course, I am sure I am doing something wrong, hogging something, BUT, I use my linux box for SMB file sharing, print sharing and SETI -- so it's all good. Good luck!

cablemodemjoey
ID: 46615 · Report as offensive

Questions and Answers : Unix/Linux : Make app run in background?


 
©2024 University of California
 
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.