I was trying to use the 'at' command.
Does it not have "resolution" to the second?
When I run it with 'at -f /tmp/tt.sh "01/21/2013 15:20:45" syntax error. Last token seen: 15:20 Garbled time
How do I run a command in the future including "seconds".
Thanks,
Jerry
From: Jerry Geis geisj@pagestation.com
To: CentOS ML centos@centos.org Sent: Monday, January 21, 2013 1:21 PM Subject: [CentOS] the at command
I was trying to use the 'at' command.
Does it not have "resolution" to the second?
When I run it with 'at -f /tmp/tt.sh "01/21/2013 15:20:45" syntax error. Last token seen: 15:20 Garbled time
How do I run a command in the future including "seconds".
Thanks,
Jerry
I think you're limited to 1 minute granularity. But if you want to run something at a specific second (ie: 13 seconds after the minute), you could modify the script to sleep for 13 seconds before running and run it on the minute, or prepend a sleep in the cron entry itself:
* * * * * sleep 13; touch /tmp/foo
______________________________________________________________________ If life gives you lemons, keep them-- because hey.. free lemons. "♥ Sticker" fixer: http://microflush.org/stuff/stickers/heartFix.html
On Mon, Jan 21, 2013 at 3:51 PM, Joseph Spenner joseph85750@yahoo.comwrote:
From: Jerry Geis geisj@pagestation.com
To: CentOS ML centos@centos.org Sent: Monday, January 21, 2013 1:21 PM Subject: [CentOS] the at command
I was trying to use the 'at' command.
Does it not have "resolution" to the second?
When I run it with 'at -f /tmp/tt.sh "01/21/2013 15:20:45" syntax error. Last token seen: 15:20 Garbled time
How do I run a command in the future including "seconds".
@Jerry: You might explain what it is you are attempting to do or why it is you need to schedule a job down to the second.
Thanks,
Jerry
I think you're limited to 1 minute granularity. But if you want to run something
Yes, both cron and at can be scheduled down to the minute (but no further). And for most jobs/situations, running every minute or every couple of minutes is suitable.
at a specific second (ie: 13 seconds after the minute), you could modify the script to sleep for 13 seconds before running and run it on the minute, or prepend a sleep in the cron entry itself:
- sleep 13; touch /tmp/foo
@Joseph: Nifty trick/hack! ;)
If life gives you lemons, keep them-- because hey.. free lemons. "♥ Sticker" fixer: http://microflush.org/stuff/stickers/heartFix.html _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
@Jerry: You might explain what it is you are attempting to do or why it is you need to schedule a job down to the second.
Thanks,
Jerry
I think you're limited to 1 minute granularity. But if you want to run something
Yes, both cron and at can be scheduled down to the minute (but no further). And for most jobs/situations, running every minute or every couple of minutes is suitable.
at a specific second (ie: 13 seconds after the minute), you could modify the script to sleep for 13 seconds before running and run it on the minute, or prepend a sleep in the cron entry itself:
- sleep 13; touch /tmp/foo
@Joseph: Nifty trick/hack! ;)
I think you might need to be careful with trying tricks to get your sub minute granularity; between things like potentially running inside a VM which seems to be able to loose ticks under high load and thus needs ntp to keep it close to true time, and ntp fudging things forwards or backwards to get back where things should be, I think you could find yourself in problems.
Not that this isn't a reasonable suggestion to attempt, just that if you really very specifically, with lots of bad consequence if you don't get it right have to run at a particular second, I think there are some pitfalls to look for.
On 01/21/2013 03:21 PM, Jerry Geis wrote:
I was trying to use the 'at' command.
Does it not have "resolution" to the second?
When I run it with 'at -f /tmp/tt.sh "01/21/2013 15:20:45" syntax error. Last token seen: 15:20 Garbled time
How do I run a command in the future including "seconds".
Thanks,
Jerry _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
from man at:
"At allows fairly complex time specifications, extending the POSIX.2 standard. It accepts times of the form HH:MM to run a job at a spe- cific time of day. (If that time is already past, the next day is assumed.) You may also specify midnight, noon, or teatime (4pm) and you can have a time-of-day suffixed with AM or PM for running in the morning or the evening. You can also say what day the job will be run, by giving a date in the form month-name day with an optional year, or giving a date of the form MMDDYY or MM/DD/YY or DD.MM.YY or YYYY-MM-DD. The specification of a date must follow the specification of the time of day. You can also give times like now + count time-units, where the time-units can be minutes, hours, days, or weeks and you can tell at to run the job today by suffixing the time with today and to run the job tomorrow by suffixing the time with tomorrow."
There is no HH:MM:SS
@Jerry: You might explain what it is you are attempting to do or why it is you need to schedule a job down to the second.
I am looking for a way to "sync" up running a command on 10 boxes at the same time. So I thought - hey in my program "I can send a command out that I want to run - this command is also another program of mine, get the current time, add 5 seconds to it, send this time HH:MM:SS to all 10 boxes and "schedule" an "at" command to run at that time. So all 10 boxes are running NTP and I thought it would be fine then if one box got it slightly faster than the last it would not matter as the "at" command would schedule the command to run all at the same time.
So what mechanizim exists to run command down to the second?
I'd rather not wait an entire 59 seconds to run the command.
Thanks,
Jerry
On 2013-01-21, Jerry Geis geisj@pagestation.com wrote:
I am looking for a way to "sync" up running a command on 10 boxes at the same time.
Why do you think you need to do that and make sure they run at exactly the same second? It seems like instead it would be better to make your command more robust to small deviations in the time at which they are run.
So what mechanizim exists to run command down to the second?
No such mechanism exists that I know of. As other posters have already mentioned, if your problem is how to execute a command on N different boxes at exactly the same second, the granularity of the at or cron commands are the least of your problems.
I suspect that, unless you can demonstrate a real need for this feature, the answers you're going to get are going to amount to "run at the top of the minute instead". (And if you can demonstrate a legitimate need, the problem is not going to be solved by at or cron.)
--keith
Why do you think you need to do that and make sure they run at exactly the same second? It seems like instead it would be better to make your command more robust to small deviations in the time at which they are run.
keith - Thanks for your reply.
I do need to run the commands at exactly the same time. It has nothing to do with making my command more "robust". It has "everything" to do with "visual" presentation that someone viewing the 10 boxes will see. if the 10 boxes are not in sync it will be completely obvious and crappy.
So if cron/at does not support it - I'll find another way.
Thanks everyone!
Jerry
On 01/21/2013 10:17 PM, Jerry Geis wrote:
Why do you think you need to do that and make sure they run at exactly the same second? It seems like instead it would be better to make your command more robust to small deviations in the time at which they are run.
keith - Thanks for your reply.
I do need to run the commands at exactly the same time. It has nothing to do with making my command more "robust". It has "everything" to do with "visual" presentation that someone viewing the 10 boxes will see. if the 10 boxes are not in sync it will be completely obvious and crappy.
you have bigger problems than startring your programs at the same time. You need very tight progamatic syncing. audio variations of more than 10ms will mess up listening. I think visual is a bit looser around 20-30ms; the eyes have more processing power?
The systems I am familiar with have realtime syncing which can't run over traditional ethernet. There ARE 802.1 standards that will meet the 10ms requirement for audio. The music people (and manufacturing automation) got that added and it works up to 2 bridge hops, but your switches/bridges/routers/APs have to support this.
Try using an digital drum to wireless headphones with more than a 10ms delay. It is impossible to drum if this occurs.
So if cron/at does not support it - I'll find another way.
Thanks everyone!
Jerry _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Jan 21, 2013, at 16:46, Jerry Geis wrote:
So I thought - hey in my program "I can send a command out that I want to run - this command is also another program of mine, get the current time, add 5 seconds to it, send this time HH:MM:SS to all 10 boxes and "schedule" an "at" command to run at that time.
Here is a crude shell script that should accomplish what you want. It is crude because it will break if you run it around midnight and does very limited parameter and no error checking. But if you pass it the time in the format HH:MM:SS followed by the command you want to run, it will start the command at the specified time.
#!/bin/sh
start=$1 shift
if [ "$(date +%T)" < "$start" ]; then echo "It's already after $start" exit 1 fi
while [ "$(date +%T)" != "$start" ]; do sleep 0.1s done
echo "Starting command at $start" eval $*
Alfred
On 01/21/2013 11:46 PM, Jerry Geis wrote:
@Jerry: You might explain what it is you are attempting to do or why it is you need to schedule a job down to the second.
I am looking for a way to "sync" up running a command on 10 boxes at the same time. So I thought - hey in my program "I can send a command out that I want to run - this command is also another program of mine, get the current time, add 5 seconds to it, send this time HH:MM:SS to all 10 boxes and "schedule" an "at" command to run at that time. So all 10 boxes are running NTP and I thought it would be fine then if one box got it slightly faster than the last it would not matter as the "at" command would schedule the command to run all at the same time.
So what mechanizim exists to run command down to the second?
I'd rather not wait an entire 59 seconds to run the command.
Thanks,
Jerry _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi Jerry,
AFAIK the at and cron command do a "best effort" to run during the minute that you have specified. There is no guarantee that the process will kick off at 00 seconds. This all depends on load etc. etc. so that scheduling a job to start on an exact second is always going to be a problem.
ChrisG
From: Jerry Geis geisj@pagestation.com
So what mechanizim exists to run command down to the second? I'd rather not wait an entire 59 seconds to run the command.
You could use a "cluster ssh" to run your commands at the same time on all hosts. You could run a script on each server that just run an infinite loop and, at a give time, runs a command.
JD
On Tue, 2013-01-22 at 02:36 -0800, John Doe wrote:
From: Jerry Geis geisj@pagestation.com
<snip>
You could use a "cluster ssh" to run your commands at the same time on all hosts. You could run a script on each server that just run an infinite loop and, at a give time, runs a command.
IMO, if one is going to a bash script, it would be better to: - calculate time to elapse until the target cmd is to run - use a sleep (maybe adjusted a tad to allow for latency)
<snip>
If all the nodes are in sync, timewise, this should get them all going close to each other.
Bill
Have the nodes subscribe to a Multicast server.
Using Pipes, Signals, and some other basic operating system course terminology the name of which escapes me at the moment.
setpriority() or nice up (-15) the priority of your software.
On 01/22/2013 01:39 PM, Rob Townley wrote:
Have the nodes subscribe to a Multicast server.
Using Pipes, Signals, and some other basic operating system course terminology the name of which escapes me at the moment.
setpriority() or nice up (-15) the priority of your software.
Good thinking.
There should only be one hop, and make that a layer 2 hop, between the multicast server and the systems. A 10ms delay through an IP router could impact the whole sync process. Again there IS 802.1 bridging designed for this; I could look it up if needed as I once did 802.1 standards, but now do 802.15 stuff...
In IPv6 you could use anycasts instead, and this is an example of what anycasts were designed for.
On Mon, Jan 21, 2013 at 4:46 PM, Jerry Geis geisj@pagestation.com wrote:
@Jerry: You might explain what it is you are attempting to do or why it is you
need
to schedule a job down to the second.
I am looking for a way to "sync" up running a command on 10 boxes at the same time. So I thought - hey in my program "I can send a command out that I want to run - this command is also another program of mine, get the current time, add 5 seconds to it, send this time HH:MM:SS to all 10 boxes and "schedule" an "at" command to run at that time. So all 10 boxes are running NTP and I thought it would be fine then if one box got it slightly faster than the last it would not matter as the "at" command would schedule the command to run all at the same time.
You're telling us how you want it to work, but not _what_ you are attempting to schedule at an interval of a few seconds.
So what mechanizim exists to run command down to the second?
Since you have the hosts' time relatively accurate via NTP this "cron/at limitation" (if we dare call it that) should not be a problem.
A cronjob scheduled at a certain time (to the minute) runs within a second or two. Of course load needs factored in, but this is unavoidable even _if_ you could schedule down to the second with cron/at.
I'd rather not wait an entire 59 seconds to run the command.
We could argue this comment. If you want something done immediately, run it by hand?!
John Doe's advice of an infinite loop or a 'clustered ssh' is probably your best bet.
Thanks,
Jerry _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Am 21.01.2013 um 21:21 schrieb Jerry Geis geisj@pagestation.com:
I was trying to use the 'at' command.
Does it not have "resolution" to the second?
When I run it with 'at -f /tmp/tt.sh "01/21/2013 15:20:45" syntax error. Last token seen: 15:20 Garbled time
How do I run a command in the future including "seconds".
http://people.redhat.com/~rjones/whenjobs/
-- LF