Finding out how long a script runs for and exit reason.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding out how long a script runs for and exit reason.
# 1  
Old 01-24-2009
Finding out how long a script runs for and exit reason.

I am running a daemon program that sends texts via a connected mobile phone. I run this daemon via CLI, and it loops a few commands (checking to see if there are any new texts).

It runs perfectly, the problem is, when I leave this to run on my Ubuntu Desktop, and come back to it hours later it has stopped running.

I need to find out why it exited, and when, so I can write a cron task to start it up periodically. - how do i do this best?

Thanks.
# 2  
Old 01-24-2009
Quote:
Originally Posted by daydreamer
I am running a daemon program that sends texts via a connected mobile phone. I run this daemon via CLI, and it loops a few commands (checking to see if there are any new texts).

It runs perfectly, the problem is, when I leave this to run on my Ubuntu Desktop, and come back to it hours later it has stopped running.

I need to find out why it exited, and when, so I can write a cron task to start it up periodically. - how do i do this best?

Thanks.

Set return codes at exit points, and put this at the top of your script:

Code:
LOGFILE=/path/to/logfile ## adjust to taste
trap 'date >> "$LOGFILE"' EXIT


# 3  
Old 01-28-2009
hey thanks alot for the code.

problem is i didnt make the daemon so i cannot put return codes at exit points.

I think it may be more ideal to check if the process is running or not, then if it isnt restart it.

ive started a new thread to make things more clearer!
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Finding largest files takes too long

Good evening. because the folder has thousand of files it takes too long and have some trouble to get the largest files and then compress files or delete it, for instance find . -size +10000000c -exec ls -ld {} \; |sort -k5n | grep -v .gz The above commad took an hour and i have to cancel... (10 Replies)
Discussion started by: alexcol
10 Replies

2. Shell Programming and Scripting

Help with finding the exit status of a 'nohup' command using 'PID'.

Hello All, I need to run a set of scripts, say 50 of them, parallely. I'm running these 50 scripts, from inside a script with the help of 'nohup' command. 1.The fifty scripts are stored in a separate file. 2.In a master script, i'm reading every line of the file through loop and executing... (4 Replies)
Discussion started by: SriRamKrish
4 Replies

3. Shell Programming and Scripting

Quick question about finding the PID of long-running processes

The end result that I'd like is to terminate any process on my ps -u username list that extends beyond 20 minutes. I know for a fact that this process will be named l.exe, but I don't know the number in between and I won't know the PID. Is there a way to use grep or pidof to do this task every 20... (2 Replies)
Discussion started by: Bolanok
2 Replies

4. Shell Programming and Scripting

How long screen command runs?

Does screen command run forever? Suppose I have following command inserted at my putty shell followed by screen # screen # export JAVA_HOME=/usr/java/jdk1.6.0_21 # export ANT_HOME=/usr/ant # export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin # export... (0 Replies)
Discussion started by: ninadgac
0 Replies

5. UNIX for Dummies Questions & Answers

finding string in very long file without newlines

What's the best way to find a string in a very long file without newlines in Unix? The standard utility I'm aware of for finding a string in a single file is grep, but for a long file without newlines, I think the output is just going to be the input. I suppose I could use sed to replace the... (5 Replies)
Discussion started by: aaronpoley
5 Replies

6. Shell Programming and Scripting

How would you return how long a script runs for?

When running a ksh script, how would you time how long it took the script ran for? Is there a command that can capture this? (1 Reply)
Discussion started by: Jazmania
1 Replies

7. Solaris

finding boot reason in solaris

hi, how do i find boot reason in solaris? i know that signal 15 reboot is a manual reboot... #cat /var/adm/messages | grep -i signal what does this mean from #last -10 "reboot system boot Sun Oct 19 09:24" is it a system boot (auto reboot by the server) or human... (5 Replies)
Discussion started by: cromohawk
5 Replies

8. UNIX for Dummies Questions & Answers

Finding out how long a command takes to run

Hi I am trying to find out the best way to find out how long a command takes to run in miliseconds .. Is there such a way of doing this in Unix ? Thanks (3 Replies)
Discussion started by: cfoxwell
3 Replies
Login or Register to Ask a Question