View previous topic :: View next topic |
Author |
Message |
dippen Tux's lil' helper
Joined: 15 Sep 2002 Posts: 83
|
Posted: Sat Dec 21, 2002 3:04 am Post subject: shutting your pc down when emerge is finished |
|
|
you know that, you sitting in front of your pc, its late at night.
you wanna go sleeping, but you think : emerge -u world will finish in few minutes.. and you wait and wait..
i got a solution.. very trivial, but it works:
start this script and your computer halts if the emerge-process is finished.
i call it haltAfterEmerge.sh
Code: | #!/bin/bash
while [ 1 ]; do
if [ -z "`ps -e | grep python`" ]; then
/sbin/halt;
exit;
fi;
sleep 2;
done;
|
it looks every two seconds for a python-process (emerge is one),
if it can't find one, it executes '/sbin/halt'
you can substitute '/sbin/halt' with 'printf \\a', then it beeps every
two seconds.... maybe to wake you up -- in some situations useful.
greetz,
dippen
excuse my poor english.. i'm working on it. |
|
Back to top |
|
|
pizen Apprentice
Joined: 23 Jun 2002 Posts: 213 Location: Atlanta, GA, USA
|
Posted: Sat Dec 21, 2002 6:40 am Post subject: |
|
|
why not just: Code: | $ emerge <whatever> && /sbin/halt |
|
|
Back to top |
|
|
bos_mindwarp Apprentice
Joined: 19 Oct 2002 Posts: 275 Location: stockholm, sweden
|
Posted: Sat Dec 21, 2002 8:36 am Post subject: |
|
|
pizen wrote: | why not just: Code: | $ emerge <whatever> && /sbin/halt |
|
because it's not high-tech? =) |
|
Back to top |
|
|
snutte Apprentice
Joined: 24 Apr 2002 Posts: 181 Location: Sweden, Malmö
|
Posted: Sat Dec 21, 2002 8:54 am Post subject: |
|
|
My vote is for the
Code: |
emerge <whatever> && poweoff
|
|
|
Back to top |
|
|
kram n00b
Joined: 29 Nov 2002 Posts: 35
|
Posted: Sat Dec 21, 2002 9:37 am Post subject: |
|
|
pizen wrote: | why not just: Code: | $ emerge <whatever> && /sbin/halt |
|
I do
Code: | $ emerge <whatever> &> ~/build.log; /sbin/halt |
so it shuts down regardless of whether the build was successful.
Can you do this once you've already started a build? Maybe if openoffice has been building for 3 hours already? |
|
Back to top |
|
|
dippen Tux's lil' helper
Joined: 15 Sep 2002 Posts: 83
|
Posted: Sat Dec 21, 2002 3:37 pm Post subject: |
|
|
Quote: | $ emerge <whatever> && /sbin/halt |
is the easiest way..
if i start an 'emerge <whatever>', i mostly dont know
if i want to shut down my computer when it is finished..
so if i want it, then i start my script.
and yes, i'm glad that its a VERY high-tech solution |
|
Back to top |
|
|
carambola5 Apprentice
Joined: 10 Jul 2002 Posts: 214
|
Posted: Sat Dec 21, 2002 6:37 pm Post subject: |
|
|
pizen wrote: | why not just: Code: | $ emerge <whatever> && /sbin/halt |
|
I think you're missing the point. The script is an "afterthought" type of thing. Say you start a merge, but after awhile, you realize it's gonna take longer than expected. If you want to do something after it's done (shutdown or beep at you), you have two choices:
- Stop the merge, and restart it with the command "emerge <blah> && /sbin/halt"
- Or, start a script with the functionality of the original post's.
I'm guessing that, since this is usually done with longer merges, that you wouldn't want to restart the process.
One interesting aspect of the function behind this script is a theoretical GUI frontend to emerge. If the user starts a batch of emerges, he/she can apply a notification event even after the emerges start by simply toggling a button. |
|
Back to top |
|
|
carambola5 Apprentice
Joined: 10 Jul 2002 Posts: 214
|
Posted: Sat Dec 21, 2002 6:37 pm Post subject: |
|
|
grr. double post. |
|
Back to top |
|
|
pizen Apprentice
Joined: 23 Jun 2002 Posts: 213 Location: Atlanta, GA, USA
|
Posted: Sat Dec 21, 2002 6:55 pm Post subject: |
|
|
carambola5 wrote: | I think you're missing the point. The script is an "afterthought" type of thing. | I realized this after reading a few posts after mine. |
|
Back to top |
|
|
snutte Apprentice
Joined: 24 Apr 2002 Posts: 181 Location: Sweden, Malmö
|
Posted: Sat Dec 21, 2002 9:59 pm Post subject: |
|
|
Btw, shutting down your computer? Hmm.. never thought of that |
|
Back to top |
|
|
delta407 Bodhisattva
Joined: 23 Apr 2002 Posts: 2876 Location: Chicago, IL
|
Posted: Sat Dec 21, 2002 11:28 pm Post subject: |
|
|
kram wrote: | Can you do this once you've already started a build? | Try:
Code: | # emerge openoffice
... emerge doing its thing ...
^Z
# fg; poweroff |
_________________ I don't believe in witty sigs. |
|
Back to top |
|
|
carambola5 Apprentice
Joined: 10 Jul 2002 Posts: 214
|
Posted: Mon Dec 23, 2002 3:06 am Post subject: |
|
|
delta407 wrote: | kram wrote: | Can you do this once you've already started a build? | Try:
Code: | # emerge openoffice
... emerge doing its thing ...
^Z
# fg; poweroff |
|
Sweet! Thanks. I've always wondered why one would suspend a job rather than kill it. I never knew how to restart a job if it had been suspended. |
|
Back to top |
|
|
water Guru
Joined: 19 Jun 2002 Posts: 387 Location: Zierikzee, The Netherlands
|
Posted: Mon Dec 23, 2002 9:50 am Post subject: |
|
|
And i stil don't know.
What does "fg"? And how do i restart after a reboot? Just emerge blahblah again (if blahblah was the emerge i stopped)? _________________ Groeten uit Holland |
|
Back to top |
|
|
Lolo- n00b
Joined: 04 Aug 2002 Posts: 62 Location: SQY (France)
|
Posted: Mon Dec 23, 2002 4:42 pm Post subject: |
|
|
fg -> foreground
bg -> background, you can launch another process right now |
|
Back to top |
|
|
Spiregrain n00b
Joined: 17 Mar 2003 Posts: 5 Location: London
|
Posted: Sun Sep 07, 2003 8:41 pm Post subject: Even easier aftertought method... |
|
|
When emerge is building, I often want to suspend the machine as soon as it's finished... so I just type apm -s<return> into the emerge window. As soon as the build is finished the characters you've typed in will appear on the command line, and get executed. |
|
Back to top |
|
|
Ian l33t
Joined: 28 Oct 2002 Posts: 834 Location: Somerville, MA
|
Posted: Sun Sep 07, 2003 10:43 pm Post subject: |
|
|
Wow, I never knew about that ^Z command before. That's so cool!!
Yes, I do feel like a little kid who just got another matchbox car :p. |
|
Back to top |
|
|
Ox- Guru
Joined: 19 Jun 2003 Posts: 305
|
Posted: Sun Sep 07, 2003 11:13 pm Post subject: |
|
|
For those who didn't know about ^Z or fg, this is documented in the job control section of the man page for your shell. Code: | man bash
/JOB CONTROL | or:
There are a lot of goodies like this in the shells |
|
Back to top |
|
|
RobMcM Apprentice
Joined: 11 Jul 2003 Posts: 170 Location: Leeds, UK
|
Posted: Sun Oct 05, 2003 2:22 pm Post subject: |
|
|
carambola5 wrote: | delta407 wrote: | kram wrote: | Can you do this once you've already started a build? | Try:
Code: | # emerge openoffice
... emerge doing its thing ...
^Z
# fg; poweroff |
|
Sweet! Thanks. I've always wondered why one would suspend a job rather than kill it. I never knew how to restart a job if it had been suspended. |
Just make sure you don't do the stupid thing I did, when towards the end of a KDE emerge I did 'bg; poweroff' instead of 'fg; poweroff' ! Oops, instant shutdown _________________ Keyboard error or no keyboard present. Press F1 to continue. |
|
Back to top |
|
|
bazik Retired Dev
Joined: 22 Jul 2002 Posts: 277 Location: Behind you.
|
Posted: Sun Oct 05, 2003 10:38 pm Post subject: |
|
|
Funny, I submitted a patch for portage which adds PRE- and POST- emerge commands a while ago. |
|
Back to top |
|
|
st589 Tux's lil' helper
Joined: 20 Sep 2003 Posts: 83
|
Posted: Sun Oct 05, 2003 10:46 pm Post subject: |
|
|
water wrote: | And i stil don't know.
What does "fg"? And how do i restart after a reboot? Just emerge blahblah again (if blahblah was the emerge i stopped)? |
I'm wondering this also Anyone know? |
|
Back to top |
|
|
RobMcM Apprentice
Joined: 11 Jul 2003 Posts: 170 Location: Leeds, UK
|
Posted: Sun Oct 05, 2003 11:20 pm Post subject: |
|
|
st12af wrote: | water wrote: | And i stil don't know.
What does "fg"? And how do i restart after a reboot? Just emerge blahblah again (if blahblah was the emerge i stopped)? |
I'm wondering this also Anyone know? |
look a couple of posts up for the bash man pages...
When there is a suspended process (like when you've used ^Z on an emerge) then will bring the suspended process back into the foreground which is how it was before you used ^Z. runs it in the background instead meaning it continues to run but you can still type stuff into the shell, like you can when you run something with the ampersand after it: Code: | # prog&
--- prog running in background ---
# other stuff here |
_________________ Keyboard error or no keyboard present. Press F1 to continue. |
|
Back to top |
|
|
Squinky86 Retired Dev
Joined: 25 Mar 2003 Posts: 309 Location: Alabama, USA
|
Posted: Mon Oct 06, 2003 1:19 am Post subject: |
|
|
While on this note, another neat thing related to fg and bg but if you're ssh'd and want to close the client computer:
# nohup emerge -uf world &
// <check nohup.txt to make sure package1 is downloaded>
# nohup emerge -u world && halt &
# exit
That's the quickest way to have emerge run on an ssh'd box you want shutdown after the upgrade. If not using ssh, it's good to replace "nohup * &" with "bg" for the emerge -uf world, and have emerge -u world run in sight to make sure nothing goes wrong.
Just my ways of speeding up portage . _________________ Me |
|
Back to top |
|
|
Ian Goldby Guru
Joined: 18 May 2002 Posts: 539 Location: (Inactive member)
|
Posted: Mon Oct 06, 2003 7:05 pm Post subject: |
|
|
Another handy emerge script:
Code: | #!/bin/bash
#
# Display system load on the keyboard LEDs
# This must be run from a console (not inside X)
while [ 1 ]
do
loadavg=`cut -d" " -f1 /proc/loadavg`
if [[ $loadavg < 0.25 ]] ; then
setleds -L -num -caps -scroll
else
if [[ $loadavg < 0.5 ]] ; then
setleds -L +num -caps -scroll
else
if [[ $loadavg < 0.75 ]] ; then
setleds -L +num +caps -scroll
else
setleds -L +num +caps +scroll
fi
fi
fi
sleep 5
done |
Switch to a console window (e.g. ctrl-alt F1) and run this. Then turn off the monitor and go and do something else. The keyboard LEDs act as a CPU load meter. Poke your head round the door an hour later and if the LEDs are out, emerge has probably finished. |
|
Back to top |
|
|
dub.wav Tux's lil' helper
Joined: 09 Apr 2003 Posts: 149 Location: Norway
|
Posted: Mon Oct 06, 2003 7:21 pm Post subject: |
|
|
Ian Goldby wrote: | Another handy emerge script:
Code: | #!/bin/bash
#
# Display system load on the keyboard LEDs
# This must be run from a console (not inside X)
while [ 1 ]
do
loadavg=`cut -d" " -f1 /proc/loadavg`
if [[ $loadavg < 0.25 ]] ; then
setleds -L -num -caps -scroll
else
if [[ $loadavg < 0.5 ]] ; then
setleds -L +num -caps -scroll
else
if [[ $loadavg < 0.75 ]] ; then
setleds -L +num +caps -scroll
else
setleds -L +num +caps +scroll
fi
fi
fi
sleep 5
done |
Switch to a console window (e.g. ctrl-alt F1) and run this. Then turn off the monitor and go and do something else. The keyboard LEDs act as a CPU load meter. Poke your head round the door an hour later and if the LEDs are out, emerge has probably finished. |
Cool Do you know if there's a xfree equivalent of setleds? After a etc-update a few weeks ago, I have to press num lock each time I restart X to be able to type / in rxvt. |
|
Back to top |
|
|
PanTast n00b
Joined: 29 Sep 2003 Posts: 5 Location: Germany
|
Posted: Mon Oct 06, 2003 10:20 pm Post subject: |
|
|
my way:
I worte a "emma.bat" like this
emerge -k xine
emerge -k mplayer
emerge -k whateveryouwant
halt
make a chmod u+x and run it as root
The advantage is: when you forgot something, you can add it to the emma.bat before the halt order.
_________________ 2 young 2 die but never 2 old 2 rock ´n roll |
|
Back to top |
|
|
|