Messages printed in the shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Messages printed in the shell
# 1  
Old 09-07-2011
Messages printed in the shell

Hi,
I would like to be able to return to the messages printed in the shell when a process is done, but I have no idea where to look for them.

[15] Done nohup script.sh (wd: ~/somesubdir)

Can anyone give me a hint? Are these messages printed by bash? They're definitely not in the .bash_history... that's commands only.
Thanks!
# 2  
Old 09-07-2011
Yes, bash itself prints them. It knows which background commands it has running and watches for them.

It prints those only to an interactive terminal, and even then, only when you're actually being active. for instance:

Code:
$ sleep 1 &
$ # it won't print the 'Done' line until we hit enter
[1]+  Done                    sleep 1
$

So I'm confused as to why it's not waiting for you. Could you show exactly what you're trying to do?
# 3  
Old 09-07-2011
It does wait for me, but sometimes in the mean time so much output is produced that I reach the limit for scrolling upwards.

I thought maybe they were saved somewhere, maybe under /proc or whatever (I found all sorts of interesting stuff in there recently, you just have to know where to look :-)

I'm working on several projects at the moment and it would help to know what to do next and where. For the time being I've been copy & pasting them to an editor, but any nicer solution would be welcome ;-) Being able to "grep" through the last few thousand lines in my shell would be an alternative...
# 4  
Old 09-07-2011
Quote:
Originally Posted by mregine
It does wait for me, but sometimes in the mean time so much output is produced that I reach the limit for scrolling upwards.
Smilie why would it be at the top if it didn't wait for you?
# 5  
Old 09-07-2011
Because I start processes which will run a while (between 10 minutes and half an hour), send them in the background, then work on a different but related project for a while, but keep on getting messages every now and then that things finished running. Usually at that point I want to finish what I'm doing (and send off some more processes), and then only return to the first topic, but by then those messages are gone (scrolled away) and I have to figure out what needs to be done next... Those messages would be a big help for my poor little memory...

Anyway, if there's no easy way to do this, it's not really important. I could also use several shells, but then I couldn't call up similar commands from the history as easily, modify a few characters and send them off again.
# 6  
Old 09-07-2011
You can trap SIGCHLD to do something whenever a background process finishes.

Code:
trap "( date ; jobs ) | tee -a joblog" SIGCHLD

This has the drawback that running jobs right then will force the [1] Done messages to happen immediately on exit -- but they'll also be printed with a timestamp, and also appended to joblog as they happen.

If you want them to just go to the logfile and not the terminal:

Code:
trap "( date ; jobs ) >> joblog" SIGCHLD

---------- Post updated at 01:00 PM ---------- Previous update was at 12:37 PM ----------

I just tested this some more and realized it happens for all jobs the shell runs, not just background ones, so not so good. Smilie
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 09-07-2011
Oh wonderful :-) A bash built-in I didn't know about and a command I had completely forgotten about (jobs). New toys to read up on and play with.

And I sort of know what commands I want to know about (scripts ending in .sh, plx, .tcl...), so I could use grep before sending the output to joblog.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk : ORS not to be printed after the last record

Hello Team, here is the code: scripts]# ls /etc/init.d/ | awk 'BEGIN{ORS=" && "} /was.init/ && !/interdependentwas/ && !/NodeAgent/ && !/dmgr/{print "\$\{service_cmd\} "$0 " status"}' 2>/dev/null ${service_cmd} cmserver_was.init status && ${service_cmd} fmserver_was.init status &&... (6 Replies)
Discussion started by: chandana.hs
6 Replies

2. UNIX for Dummies Questions & Answers

How to get " printed on command line?

Hey, Is there a way I can print " in a command line? When I type "echo "set variable = disco"".... This actually prints echo set variable = disco but I would like to print it out as --- echo "set variable = disco" Thanks, Satya (4 Replies)
Discussion started by: Indra2011
4 Replies

3. Shell Programming and Scripting

Value not getting printed outside loop

Hi all I'm using below code #!/bin/bash export fileclob cd /home/appsuser/dataload file='EG.mdd' chmod 777 $file dos2unix -ascii -k -q -o $file $file sed -e '${/^$/d}' $file cat $file | while read LINE do echo "line is" if then echo "line is $LINE" echo " " ... (10 Replies)
Discussion started by: Pratiksha Mehra
10 Replies

4. Shell Programming and Scripting

Variable value not getting printed

Hi, I ma trying to do this but don't know why it is not happening? $r1=10 for i in "1" "2" "3" "4"; do x=`eval echo $i`; echo r${x}; done output: r1 r2 r3 r4 also tried for i in "1" "2" "3" "4"; do x=`eval echo $i`; echo $r${x}; done output: 1 (2 Replies)
Discussion started by: abhi1988sri
2 Replies

5. Shell Programming and Scripting

Need to limit the status printed

Hi, I have the data set as below, 0221500612134|Nutro 30-35 lb. Dry Dg 3 of 10 08/29/13~ 0221503074850|Nutro 30-35 lb. Dry Dg 1 of 10 09/23/13~ 0221503499660|Blue Buff 24-30lb Dog F 1 of 10 02/26/13~ 0221503499660|Iams 15.5-20lb Dog Food 2 of 10 11/12/12~ 0221503499660|Nat Blnc 25-35lb Dog... (1 Reply)
Discussion started by: anandek
1 Replies

6. Programming

Value printed by gdb does not consist with the right value

Hello, I find the value printed by gdb does not consist with the right value.The following is the output. (gdb) 7 while ( ( optc = getopt(argc, argv, ":b:B:h" ) ) != -1 ) { (gdb) 8 printf( "%c %d %s\n", optc, optind, optarg); (gdb) B 5 1-2 7 while ( ( optc =... (1 Reply)
Discussion started by: 915086731
1 Replies

7. UNIX for Dummies Questions & Answers

Python update already printed line.

Hi. I have a basic script in python that outputs like this.. $ ./test.py 1% 2% 3% 4% 5% 6% 7% 8% 9% 10% ... But how can I make it so the output stays in 1 line? So it would look something like this.. $ ./test.py 10% (1 Reply)
Discussion started by: cbreiny
1 Replies

8. UNIX for Dummies Questions & Answers

How to exclude files from printed results

Hello I have application that part of its command I can get list of files to the stout . with the path . like : ./blah/blah/foo.c ./blah11/blah11/foo11.c ./blah12/blah12/foo11.h now I will like to filter this result and for instance see the "*.h" file or the "*.c" file or only the files... (2 Replies)
Discussion started by: umen
2 Replies

9. UNIX for Advanced & Expert Users

lp - order of files printed

I have a shell script that is looping through a list of Postscript files to print. ls -1tr *.PS > print.lst ... PRINT_LIST=`cat print.lst` ... for DMFILE in $PRINT_LIST do lp -d $PRINTER_NAME -o legal $DMFILE ... done The files in print.lst are in the order that they should be... (2 Replies)
Discussion started by: mabrownawa
2 Replies
Login or Register to Ask a Question