cron job execution...

Link to this post 03 Jun 10

$crontab -e
* * * * * /root/ >> /root/cronJobExecuted.log

sh /root/

One of my web application will keep on insert list of ssh command in my file "" such as
ssh -i key.pem root@<host1> -C sh /mnt/ >> /root/Output.txt
ssh -i key.pem root@<host2> -C sh /mnt/ >> /root/Output.txt

In remote machine,
echo `cat /mnt/imageOutput.txt`

Source: imageOutput.txt

As soon as when ssh get executed in, I should not execute it again.
How is should handle this...


Cronjob has executed 1) ssh -i key.pem root@<host1> -C sh /mnt/ >> /root/Output.txt
and 2)ssh -i key.pem root@<host2> -C sh /mnt/ >> /root/Output.txt

Again when cronjob trying to execute, it should skip the above 2 ssh command , it should execute only the new command if and only if exist....How i can handle this ?

Link to this post 12 Jun 10

Well, clearly, you need either remove the ssh commands as they're being executed in your scripts, or you need to add some other inteligence into your scripts. You could, for example have check the number of lines in the file and keep track of that number in some other file somewhere in the file system, and then only execute the number of lines above the last saved number of lines. Or, make the script that puts the lines into remove old lines.

before anyone here can give you any more advice, I think you'll have to explain a little more about what exactly it is that you're trying to accomplish and give us a better picture of all the pieces and how they all interact.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board