Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I need some help with this cron job I have to run.
It looks like this:
*/1 * * * * time /home/user/script.pl | mail -s "blah-blah-execution_`date +\%H:\%M_\%D`" email@example.com >/dev/null
As you can easily see I use 'time' before my perl script as I need to know how long the script will take to execute/finish.
Actually, this is the only info I need to get by email. The job runs only that now I get by email the script output results and not the execution time.
Calling a cron job every minute is going to hammer your system somewhat, as cron had to crate an entire new process environment for each invocation.
My rule of thumb is that for any more frequent that every 5 mins, create a daemon instead, optionally pausing at the bottom of the loop for as long as reqd.
Also, with this soln, you can grab current time at top of processing loop, then again at the bottom & incorporate the email cmd (with time diff) at the bottom of each loop.
Okay, I've tried the last one, number 3.
If I run it in console it will give me the execution time but on email I will get the results/output from the script.
I don't need them ! I just need the script running time, that's all.
It still doesn't work. I get the output/result from the script and not the output from 'time'.
As I told before I don't need the output from script because it's a bg script that runs more the 30 minutes and the output is huge. I only need that bloody output from 'time'. It seems that it's harder then I previous thought.
Unfortunately it emails all output, once from the script and second from time command. If I could find a way to run the script and just send by email the execution time will be awesome, but for now I'm happy with this.
1. amend the Perl prog to redirect its stdout+stderr to a file (or /dev/null if you REALLY don't need it; BUT then why is it outputting anything?)
In either case you get .pl to only output (to stdout) the reqd elapsed time
2. put the .pl in the subshell only;
my test looks like this
# without redir: t.sh just does 'echo $SHELL'
#throw t.sh output away
time (./t.sh >t.t)