Send sleep to background


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Send sleep to background
# 8  
Old 03-11-2016
Dude, try:
Code:
while [ ! -f /tmp/checkfile.txt ]
do
	sleep 3
done
echo "File exists now"

Or if i may talk about using TUI:
Code:
while [ ! -f /tmp/checkfile.txt ]
do
	tui-wait 3 "Checking for file in..."
done
tui-status $? "Found file"

hth

Last edited by sea; 03-11-2016 at 10:07 AM..
# 9  
Old 03-11-2016
Hi RudiC,

I use the below part inside another shell script (parent script) where the parent script is executed as "sh -ex parent.sh".

until [ -f /tmp/examplefile.txt ]
do
/bin/sleep 3
done
echo "File found"

If the above is a standalone script, I can run it by just using "sh" as per Scrutinizer. Works great.

Since this part is inside another script, I get the output as below.

07:53:09 + '[' -f /opt/cc...... ']'
07:53:09 + sleep 5
07:53:11 + '[' -f /opt/cc...... ']'
07:53:11 + sleep 5
07:53:19 + '[' -f /opt/cc...... ']'
07:53:19 + sleep 5
07:53:21 + '[' -f /opt/cc...... ']'
07:53:21 + sleep 5
07:53:28 + '[' -f /opt/cc...... ']'
07:53:28 + sleep 5
07:53:32 + '[' -f /opt/cc...... ']'
07:53:32 + sleep 5
07:53:36 + '[' -f /opt/cc...... ']'
07:53:36 + sleep 5
07:53:41 + '[' -f /opt/cc...... ']'
07:53:41 + sleep 5
07:53:46 + '[' -f /opt/cc...... ']'
07:53:46 + sleep 5
07:53:51 + '[' -f /opt/cc...... ']'
07:53:51 + sleep 5
07:53:56 + '[' -f /opt/cc...... ']'
07:53:56 + sleep 5
07:54:01 + '[' -f /opt/cc...... ']'
07:54:01 + sleep 5
07:54:06 + '[' -f /opt/cc...... ']'
07:54:06 + sleep 5
07:54:11 + '[' -f /opt/cc...... ']'

@sea:

first method works great if I execute it as ./test.sh or sh test.sh.
since this is inside another script, it didn't work.

This is what i get if use your second method.
tui-wait: command not found
# 10  
Old 03-11-2016
So - what's wrong? Above is exactly what would be expected, except mayhap the timing in the first three or four loops.
# 11  
Old 03-11-2016
I want to send these message to background or stop it from printing on screen. From developers point of view, these should not be visible from the output log.
# 12  
Old 03-11-2016
You probably have a set -x inside your script somewhere.
That is what is causes that output, not 'some' error of the code.

Yes, as i've said, "if i may talk about using TUI", those commands are not (yet) part of the default installations.
Wanted to link there, but it seems the thread and its 8 pages is gone from the "Scripts & Programming" sticky section??

---------- Post updated at 19:30 ---------- Previous update was at 19:25 ----------

There is no output log, unless you do log the (specified) output.
That is not applicable here (from what we've seen here).

You could do like:
Code:
/path/script.sh 2>/path/to/logfile.everything >&2
# OR
/path/script.sh 2>/path/to/logfile.error >/path/to/logfile.stdout
# OR
/path/script.sh >/path/to/logfile.stdout

EDIT:
But usualy, you only want:
Code:
/path/script.sh 2>/path/to/logfile.error

hth
# 13  
Old 03-11-2016
Quote:
Originally Posted by builderj
I want to send these message to background or stop it from printing on screen. From developers point of view, these should not be visible from the output log.
But - - - you've been told by Scrutinizer NOT to use the -x option?
# 14  
Old 03-11-2016
Err...
And from within said /path/script.sh, the this would be some sample code:
Code:
echo "this is default output" >&1
echo "this is an error message" >&2
echo_fails "This line (its error message) will appear in the error log"
echo "This message will appear in the stdout logfile, if redirected"

hth
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Send current script to background

Hi scripters, I'm quite used to run commands in the background using & like in: $ myscript &But this is NOT what I'm trying to do today. What I'm trying to achieve is to run a script the normal way (without &), have my script do a little checkup and then jump to background. Something like:... (5 Replies)
Discussion started by: chebarbudo
5 Replies

2. UNIX for Dummies Questions & Answers

How do I send output of a background process to a file other than nohup.out?

I have a question. I will be running a background process using nohup and & command at end. I want to send output to a file say myprocess.out. So will this command work? nohup myprocess.ksh > myprocess.out & Thanks in advance guys !!! :) (3 Replies)
Discussion started by: vx04
3 Replies

3. UNIX for Dummies Questions & Answers

Send job to Background after input redirection

Hi, I am having issues with syntax when I am trying to send a job to the background after a input redirection. I have this script which sends some files to different servers after zipping them. Once I execute it, it will ask for user input as of which server the files need to go to. (The... (3 Replies)
Discussion started by: grep_me
3 Replies

4. Shell Programming and Scripting

Need help regarding sending sleep to background

Hi, can we print anything, when sleep is running..? like printing dots(.. . . . . . . . .) to indicate that some process is going on...? i mean, can we send sleep to background, proceed with printing, till sleep is going on... in s single step. I have written a funtion to solve this. ... (1 Reply)
Discussion started by: Dpu
1 Replies

5. Shell Programming and Scripting

Send Foreground job to background redirecting output

I have many CPU intensive processes running and sometimes I run them in the foreground so that I can see what the output is. I want to send that foreground process to the background, but also have it direct the output to a logfile. I know to send something to the bg I do Ctrl-z on the FG... (6 Replies)
Discussion started by: jhullbuzz
6 Replies

6. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

7. UNIX for Advanced & Expert Users

send a new value to a variable in a running background process

Hi guys, I have a issue with a background process, I need to update the value of a variable in that process which is running at this time and it will be running for at least 2 days. Any idea? I will apreciate your help. regards. Razziel. (2 Replies)
Discussion started by: razziel
2 Replies

8. Shell Programming and Scripting

Send password : In Background

Hi All, How to pass the password in background.....? " /usr/bin/hdiutil attach -mountroot -stdinpass /path/to/mount/ /path/of/image/TEST.sparseimage " The above command asks the password to mount a sparse image and when supplied it gets mount. But my requirement is to use... (1 Reply)
Discussion started by: ashwin.patil
1 Replies

9. UNIX for Dummies Questions & Answers

Sleep - Send Email

Working on a script to look in a directory for a certain file. If the file is not there, check the time. If the time is greater than 10:00, send me an email. If it's not, sleep for 15 minutes and then do this all over again. I can get it to email me if the file's not there without the sleep... (4 Replies)
Discussion started by: dstinsman
4 Replies
Login or Register to Ask a Question