cron, run at yyyy-mm-dd hh:ii:SS?
Hey, so I've searched these forums, and google, but all I find is how to run a script every 5 seconds, or something like that. But that is not what I'm looking to do.
Say I want to launch a command at 2009-11-30 at 21:04:22 (yes, with seconds). How would I go about to launch this, as cron doesn't take seconds. I've read about making scripts that loops every 1 second or so, but I'm not sure of how to do that. What I would like to do is make a php-script that adds dates+times to launch specific command into cron? Hope you understand what I mean. Any help appreciated. -p |
Maybe this should work, (for 2009-11-30 at 21:04:22 as in OP)
in cron: Code:
04 21 30 11 sleep 22; /runthis Code:
04 21 30 11 php runthis.php 22 PHP Code:
|
Maybe you should use at for that.
|
Quote:
I didn't know about that command :redface: I tried this: Code:
> at 2009-11-25 22:01:05 echo hello Code:
syntax error. Last token seen: 22:01 |
Please :)
man at |
well it didn't make any sense.
It said i should be able to type something like MMDDYY or HH:MM. I didn't get it to work cause there was nothing there explaining the syntax. I tried: at MMDDYY HH:MM but that didn't work.. but I should have used: at HH:MM MMDDYY which seems to work. But there are still no seconds in At? just like cron :( |
The cron + sleep 22 seconds is prob going to be the easiest. Note that cron is used when you want a process to run repeatedly over time. at is for one shot processes.
As per the man pages http://linux.die.net/man/1/at http://linux.die.net/man/5/crontab you can only specify a starting time to the nearest minute. |
FYI one can not be absolutely sure that a job will start at precisely 00 seconds. In addition jobs are executed in a top down fashion so the order of tasks in the crontab file will be important if you have multiple jobs that run at the same minute.
|
Thank you all for your replies. I have gotten so far now that I am executing
php /var/www/test.php | at -t 200911262230 the problem with this is that it runs the command when I hit Enter, not when it reaches 2009-11-26 22:30. What am I doing wrong here? |
never mind that last post, i just got
echo "ls -li" | at -t 200911262228 to work.. I will do some more testing. |
this is really weird..
first: dummy.php PHP Code:
Code:
php /var/www/auto/dummy.php 10 < /dev/null | at -t 200911262256 |
Code:
sleep 10; php /var/www/auto/dummy.php < /dev/null | at -t 200911262256 |
so, doing it like this:
Code:
x@x:/> at -t 200911262336 Can someone point me in the right direction here, cause I'm lost. /usr/bin/php /var/www/dummy.php 10 | at -t 200911262336 is not working. |
Quote:
Because you're tying to feed the output of the the command to at. What you WANT to do is: Code:
echo "/usr/bin/php /var/www/dummy.php 10"| at -t 200911262336 Cheers, Tink |
Thank you so much Tink, this works.
|
All times are GMT -5. The time now is 03:34 PM. |