Sponsored Content
Top Forums Shell Programming and Scripting Determine amount of time to process Post 302461345 by Neo on Sunday 10th of October 2010 02:48:21 PM
Old 10-10-2010
Here is a PERL example, from one of my scripts:

perl code:
  1. $mtime = microtime();
  2. $mtime = explode(' ', $mtime);
  3. $mtime = $mtime[1] + $mtime[0];
  4. $starttime = $mtime;
  5. // your system commands / work here
  6. $mtime = microtime();
  7. $mtime = explode(" ", $mtime);
  8. $mtime = $mtime[1] + $mtime[0];
  9. $endtime = $mtime;
  10. $totaltime = ($endtime - $starttime);
  11. //
  12. // do some more stuff
  13. //
  14. $to = "me@whereiam.com";
  15. $subject = "My Subject";
  16. $body = "Process executed in " .$totaltime. " seconds.";
  17. $header = "From: me @ whereiwas . com]\r\n";
  18. $header .= "Return-Path: me @ whereiwas . com\r\n";
  19. $header .= "Reply-To: me @ whereiwas . com\r\n";
  20. $success = mail($to, $subject, $body, $header);
  21. //
  22. // email addresses with spaces added
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

executing a script for a certain amount of time

I am writing a script that takes two parameters: the name of another script and an integer that represents a number of seconds. The script must execute the second script (first parameter) for the specified number of seconds (second parameter), suspend it for the same number of seconds, and continue... (9 Replies)
Discussion started by: ponchorage
9 Replies

2. UNIX for Dummies Questions & Answers

Determine which file is invoking process?

Hey Guys, I am trying to figure out what is chewing up a bunch of CPU on our SunFire V120 Boxes and I am having a little trouble drilling down the source. When I check the CPU usage it displays tail & cat as the top two processes PID USERNAME SIZE RSS STATE PRI NICE TIME CPU... (1 Reply)
Discussion started by: Jerrad
1 Replies

3. AIX

How to determine what process is actively using my harddisk?

Hi, Is there any command that I can issue to check who is actively using my harddisk? I notice that yesterday the hdisk0 and hdisk1 is really actively being used and is reaching almost 100%. I realized that this is because of paging which is climbing up to 70%. However, just this morning... (3 Replies)
Discussion started by: depam
3 Replies

4. UNIX for Dummies Questions & Answers

determine total memory used by some user/process

HI guys, :confused:i would like to know how can i determine the total/approx memory used by a single user. Example Top output is below =========================================================================== top - 20:00:50 up 24 days, 2:48, 2 users, load average: 0.43, 0.40, 0.37... (3 Replies)
Discussion started by: cromohawk
3 Replies

5. UNIX for Dummies Questions & Answers

Script to determine logged in time

Hi all So I am thinking my inability to cope with math is bogging me down here so Im asking for help. I want to determine how long a user has been logged on for by using the date and who commands to determine the time they have been logge don. My problem is that I keep getting the wrong... (2 Replies)
Discussion started by: losingit
2 Replies

6. Shell Programming and Scripting

Determine previous time in minutes

I have several logs with where the time stamp in the logs are "YYYYMMDDHHMM". I would like to check the last line in each file to make sure the entry is less than 5 minutes old. My timezone is EST5EDT so the following will work for 1 hour. But I need something easy for 5 minutes ago.... (5 Replies)
Discussion started by: oldman2
5 Replies

7. UNIX for Advanced & Expert Users

Kill a process after a certain amount of time

I would like to kill a process after a certain amount of time. Can I please get some ideas on how to do this? (9 Replies)
Discussion started by: cokedude
9 Replies

8. UNIX for Dummies Questions & Answers

How to determine nfs mount time

Hi There are numerous mounts on my local system from various other remote machines. I was looking for some way to determine the time stamp when the drives are mounted. like say if there is a mount name backup on local system. I want to determine the timestamp when it was mounted. any... (3 Replies)
Discussion started by: rakeshkumar
3 Replies

9. Shell Programming and Scripting

How to determine the completion of a background process to trigger something else?

I've been thinking about a peculiar problem, and so far haven't been able to find out a convincing solution to that. To put it simply, I have a shell script (assume it to be parent_script.sh), calling another shell script (child_script.sh) 5 times, in nohup mode to be executed in the background.... (3 Replies)
Discussion started by: Aviktheory11
3 Replies

10. Shell Programming and Scripting

Run a command for specific amount of time with an auto key press

Hi, I have been trying to do a small fun project for myself. I want to run a command for 45 seconds. And to get the final output of this command, the script requires I push the "q" key on my keyboard and then the final output file becomes available. I tried the following script. But it... (12 Replies)
Discussion started by: jacobs.smith
12 Replies
All times are GMT -4. The time now is 03:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy