您的位置:首页 > 运维架构 > Shell

linux 下 将 shell script 与 一个桌面图标联系在一起 (2)

2009-05-22 13:35 621 查看
Cy163注:

步骤如下:

(1) 建立 xxxxx.sh

(2) 在 vnc 虚拟终端 的desktop上,右键,然后选择“创建启动器”

(3) 类型选择 “应用程序”。其实选择其它选项 ,也可以。

(4) 不要选择 “在终端中运行”

注:自己的linux版本是 RedHat Linux Advanced Server 4

http://setiathome.berkeley.edu/forum_thread.php?id=142

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

Darren
Volunteer tester

Send message
Joined: Jul 2 99
Posts: 259
ID: 24497
Credit: 275,132
RAC: 0

窗体顶端

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 |

Merlin
Volunteer tester
Send message
Joined: Nov 24 99
Posts: 18
ID: 29609
Credit: 1,265,222
RAC: 0

窗体顶端

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 |

Mark Bauer
Send message
Joined: Apr 3 99
Posts: 3
ID: 3339872
Credit: 351,503
RAC: 311

窗体顶端

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 |

jkmobrien
Send message
Joined: Dec 8 00
Posts: 7
ID: 31330
Credit: 260,674
RAC: 0

窗体顶端

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 |

Trane Francks
Send message
Joined: Jun 18 99
Posts: 221
ID: 13752
Credit: 122,319
RAC: 0

窗体顶端

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 |

S@NL - rob
Send message
Joined: Oct 2 99
Posts: 10
ID: 84013
Credit: 124,589
RAC: 0

窗体顶端

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 |

repi
Send message
Joined: Oct 29 00
Posts: 5
ID: 9239
Credit: 194,630
RAC: 0

窗体顶端

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 |

not in use
Send message
Joined: Jun 22 01
Posts: 32
ID: 802260
Credit: 1,554
RAC: 0

窗体顶端

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 |

Yavin
Send message
Joined: Jul 15 04
Posts: 3
ID: 7795173
Credit: 19,749
RAC: 0

窗体顶端

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 |

Jaguar
Send message
Joined: Jan 4 04
Posts: 1
ID: 552048
Credit: 16,438
RAC: 0

窗体顶端

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 |

Jean-Pierre Godet
Send message
Joined: Sep 12 99
Posts: 4
ID: 1508644
Credit: 17,167
RAC: 0

窗体顶端

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 |

Joseph
Send message
Joined: Mar 28 02
Posts: 1
ID: 454061
Credit: 38,344
RAC: 2

窗体顶端

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 |

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: