pausing a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pausing a script
# 1  
Old 04-18-2005
Computer pausing a script

hello all, I have a script (Solaris v8 ksh) monitoring an inbound directory for reports. The script will then capture the report based on a set of circumstances. However I am unable to capture a report larger then 2-Gig in size due to program limitations. What I need to do is pause the monitor script wile it moves the selected large report, and then resume when the process completes. This is a snippet of what I've come up with, but it doesn't pause the script!

#!/bin/ksh -m -i
if [ "`head -1 $QMLARGEDIR/bigfile.lst`" != "" ]; then
for files in $(<$QMLARGEDIR/bigfile.lst); do
echo "Report: $files Exceeds the file size limit"
echo "Moving it to the: $QMLARGEDIR Directory"
mv $INBOUNDMAINDIR/$files $QMLARGEDIR/$files %%
wait $!
done

even better would be to do a specific process wait. I believe it would be done like this, but not sure:

wait %?$files

Any help and/or suggestions would be fantastic, and greatly appreciated. Thanks guys.
# 2  
Old 04-18-2005
why don't you just make the next command dependent on the mv command?

Code:
#!/bin/ksh -m -i
if [ "`head -1 $QMLARGEDIR/bigfile.lst`" != "" ]; then
    for files in $(<$QMLARGEDIR/bigfile.lst); do
        echo "Report: $files Exceeds the file size limit"
        echo "Moving it to the: $QMLARGEDIR Directory"
        mv $INBOUNDMAINDIR/$files $QMLARGEDIR/$files && next_command
    done
fi

# 3  
Old 04-18-2005
your code as modified here --- note the missing "wait $!" and "&& next_command" --- will by itself wait until the earlier big file is done moving prior to continuing with the loop ... no need to pause the script ...
Code:
#!/bin/ksh -m -i
if [ "`head -1 $QMLARGEDIR/bigfile.lst`" != "" ]; then
    for files in $(<$QMLARGEDIR/bigfile.lst); do
        echo "Report: $files Exceeds the file size limit"
        echo "Moving it to the: $QMLARGEDIR Directory"
        mv $INBOUNDMAINDIR/$files $QMLARGEDIR/$files
    done
fi

# 4  
Old 04-19-2005
As the script stands it executes the move and immediately jumps to the next group of statements. This is merely a small addition piece to the larger script.
# 5  
Old 04-19-2005
Quote:
Originally Posted by gozer13
As the script stands it executes the move and immediately jumps to the next group of statements.
What's wrong with that? The move is finished before the next statement is executed.
# 6  
Old 04-19-2005
The move takes about five + min to complete. Because the script doesn't pause, the remainder of the script will attempt to capture the same report that is being moved, as it has not been fully removed from the inbound monitor directory, hense a program crash.

Oh a correction, at the end of the move command I have tried a '&' not the '%%'. I think the '%%' designates a selection of the current background process yes?
# 7  
Old 04-19-2005
& puts a command in the background. So just don't do that. Whether the move takes five minutes or five days, the script will wait for it to complete. Commands in a script are executed sequentially.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

2. Shell Programming and Scripting

Oracle/SQLPlus help - ksh Script calling .sql file not 'pausing' at ACCEPT, can't figure out why

Hi, I am trying to write a script that calls an Oracle SQL file who in turns call another SQL file. This same SQL file has to be run against the same database but using different username and password at each loop. The first SQL file is basically a connection test and it is supposed to sort... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

Pausing a cron job

Hi All, I have a cronjob which runs a script every 5 mins. My problem is before the script is completed the cron job starts again after 5 mins. How can I put this second cron job to wait unless the first script has completed. Could you please help me on that (7 Replies)
Discussion started by: prats_7678
7 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

Read not prompting/ pausing for input

Heya people, So my script is one of those make-user-scripts, making a bunch of directories in the home folder and copying some files over into the new directories. However, part of the thing my script need to do is check the home folder if a username matches with a directory which already exists.... (6 Replies)
Discussion started by: Cloudy_Cat
6 Replies

6. UNIX for Dummies Questions & Answers

Pausing and resuming process on laptop

Hi, I'm wondering if it's possible to pause a process I'm running in the background, close my laptop (I need to leave the office), and continue the process (when I get home). I've been running a process for a really long time and I don't want to have to start it over. Thanks in advance! (9 Replies)
Discussion started by: ShiGua
9 Replies

7. Shell Programming and Scripting

Pausing between two executions in a shell script

HI, Please help me on this. I have to execute 100 scripts which i have redirected in to a file . I want to pause the script after first execution and once i say enter key word it has to go to next execution. My looks like for RUNFILES in `cat ${SOURCEFILES}/scripts` do echo $RUNFILES; ... (1 Reply)
Discussion started by: srichunduru
1 Replies

8. Shell Programming and Scripting

Pausing function with Perl

Hi all, I got the request to make a Perl script with the requirements as follow: 1. Make a program that just shows the time, a clock on the format 12:01:24. 2. When someone press key combination Ctrl -p the program should pause, ie the clock will stand still. When the Ctrl - p is pressed... (3 Replies)
Discussion started by: milo
3 Replies

9. Shell Programming and Scripting

read is not pausing to read

Can anyone tell me why this section of my script doesn't work? The script is designed to accept piped data, store it in a temporary location, and then prompt the user for their user name. It doesn't stop to read the username, however. It just finishes. It is called like: cat datafile | myscript... (3 Replies)
Discussion started by: davegerdt
3 Replies

10. Shell Programming and Scripting

Pausing a Grep output

I am writing a small script which allows users to grep multiple log files across multiple directories, and often the output produced by the grep statements is quite lengthy. It would be nice if the output to the screen could be "paused" when it reaches a certain length (say, the length of the... (5 Replies)
Discussion started by: mharley
5 Replies
Login or Register to Ask a Question