I want to run a command at something like 1 second intervals (the timing isn't at all critical), it's a background task with no screen output.
So I want something like 'watch' but which will run without a terminal, and I also want to be sure that the command will always get run. Thus something like a loop in bash with a 'sleep 1' in it isn't suitable because if the command dies it won't restart.
I.e. it's a cron job with a 1 second repeat rate and non-critical timing, any ideas anyone?
Hi Chris,
If the timing isn't important, is there anything to stop you writing the script with sleep 1 in it ~59 times and then running the script every minute in cron?
That way, even if the script dies, you only have to wait at most a minute before it tries again
Cheers On 16 Aug 2014 17:02, "Chris Green" cl@isbd.net wrote:
I want to run a command at something like 1 second intervals (the timing isn't at all critical), it's a background task with no screen output.
So I want something like 'watch' but which will run without a terminal, and I also want to be sure that the command will always get run. Thus something like a loop in bash with a 'sleep 1' in it isn't suitable because if the command dies it won't restart.
I.e. it's a cron job with a 1 second repeat rate and non-critical timing, any ideas anyone?
-- Chris Green
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
On Sat, Aug 16, 2014 at 05:07:49PM +0100, Paul Lenton wrote:
Hi Chris,
If the timing isn't important, is there anything to stop you writing the script with sleep 1 in it ~59 times and then running the script every minute in cron?
That did occur to me too, I suspect it may be the most practical method.
That way, even if the script dies, you only have to wait at most a minute before it tries again
Yes.
On 19/08/14 19:12, Chris Green wrote:
On Sat, Aug 16, 2014 at 05:07:49PM +0100, Paul Lenton wrote:
Hi Chris, If the timing isn't important, is there anything to stop you writing the script with sleep 1 in it ~59 times and then running the script every minute in cron?
That did occur to me too, I suspect it may be the most practical method.
That way, even if the script dies, you only have to wait at most a minute before it tries again
Yes.
Would inittab with respawn be a better way to start it. That way it would restart if it failed?
http://www.linuxquestions.org/questions/linux-server-73/how-to-respawn-a-ser...
Steve
On Tue, Aug 19, 2014 at 09:43:37PM +0100, steve-ALUG@hst.me.uk wrote:
On 19/08/14 19:12, Chris Green wrote:
On Sat, Aug 16, 2014 at 05:07:49PM +0100, Paul Lenton wrote:
Hi Chris,
If the timing isn't important, is there anything to stop you writing the script with sleep 1 in it ~59 times and then running the script every minute in cron?
That did occur to me too, I suspect it may be the most practical method.
That way, even if the script dies, you only have to wait at most a minute before it tries again
Yes.
Would inittab with respawn be a better way to start it. That way it would restart if it failed?
http://www.linuxquestions.org/questions/linux-server-73/how-to-respawn-a-ser...
Now that feels like the 'proper' way to do it, thanks for the idea.
However modern (as in what I use!) Linux systems don't use inittab.
There is of course an equivalent though which is well described in the init(5) man page. There's even a whole system for *user* initialised services which is even better! :-)
It rather makes autossh unnecessary, run your ssh reverse-tunnel creating process(es) as upstart services. (See another thread)