I am writing a shell script that will be used to automate cold backup of an Oracle Database. The database size is around 300G and will take around 5-6 hours to copy.
I have finished the script till the copy of the datafiles. Now, I am stuck at the point where I need to monitor the copy process.
I usually use while loop to monitor any long running process as below:
Now, my question is, is this the only way? Is someone using any other method to monitor a long running process?
I usually use while loop to monitor any long running process as below:
In my opinion, this is a very poor approach, as it is very vulnerable to false positives. What if a different command with a different pid contains an argument that matches the pid being grepped for? This code will not detect that the monitored process has died/exited. What's much worse, however, is that depending on the kernel process scheduler and the shell implementation, the grep command's pid argument itself could trigger a false positive when groveling through the ps output (and given the way this code is structured, to test for equality to zero as failure, this could be happening often ... silently).
I would (perhaps melodramatically ) characterize this as an indiscriminate grepping of ps output. When dealing with multicolumn output whose values can collide (the arguments field, for example, can conceivably contain a username/pid/ppid/...), it is safer and easier to constrain the match to a specific column using AWK. And, if applicable, use ps' output options to limit output only to the fields that are necessary. If you are grepping for a pid, why not use a ps output format that only prints pid?
Instead of ...
I would suggest ...
Or, you could grep|wc the output of "ps -o pid= -p <long running process id>", if that feels more familiar
Alister and ygemici, Thanks a lot for your invaluable suggestions and tips.
My friend also suggested one solution.
Since the backup will take a minimum of 5-6 hours, instead of writing a script that has to sleep till the backup is complete, why not, schedule a cronjob that runs say 4 hours after the backup is kicked off.
This script can check if the backup is still running and exit if it is. If the backup is not running (i.e., it is finished), check whether the database is up or not and depending on that, start it up.
Seems like a workable solution instead of using the sleep command till the script complete.
Alister and ygemici, Thanks a lot for your invaluable suggestions and tips.
My friend also suggested one solution.
Since the backup will take a minimum of 5-6 hours, instead of writing a script that has to sleep till the backup is complete, why not, schedule a cronjob that runs say 4 hours after the backup is kicked off.
This script can check if the backup is still running and exit if it is. If the backup is not running (i.e., it is finished), check whether the database is up or not and depending on that, start it up.
Seems like a workable solution instead of using the sleep command till the script complete.
What say?
Regards,
Praveen
we know work times of oracle cp process or automatic in random times or related anything ?
Team,
I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list.
How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
I am running a script which will read the data from fail line by line and call the Java program by providing the arguments from the each line.
The Java code is working fast for few records and for some records its getting hanged not providing response for morethan one hour.
Currently am... (4 Replies)
I want to write a shellscript which determines if a particular process is long running than my specified threshold time.
Eg:
My process name is "prsd" and is expected to run for 15 mins and completes. If I set a threshold limit of 1 hour,
and how we can the get output of the long running... (4 Replies)
get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same.
hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Hello all,
I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted.
Thanks in advance
Regards,
pradeep kulkarni.
:mad: (13 Replies)
I have a requirement to check how long a process is running on unix system.If i use ps -ef i am getting the following message
guest 2453638 1998920 0 16:16:05 - 0:00 dsapi_slave 9 8 0
but this is showing only time not the date.Can any one please advice me any script to find out how... (2 Replies)
I would like to know if i can monitor if a process is running.
I have one program wich is running all the time, called oliba, but sometimes it goes down, and I have to launch it again.
Is there a way to monitor the pid of the program, and if the program goes down, to lauch it again?
Can you give... (3 Replies)