Run a command at a specific time

Eamorr picture Eamorr · Apr 20, 2011 · Viewed 46.7k times · Source

I'm trying to run a command at a specific time. I've looked at the "at" command, but I don't know how to get it working...

Here's what I do:

at 1843 (Enter)
php /run/this/script.php (Ctrl+D)

But how do I do this in a bash script? I mean, I need to press enter and "Ctrl+D" to set up the delay... How to do this in a script?

Any suggestions most welcome.

Thanks in advance,

Answer

Michael Berkowski picture Michael Berkowski · Apr 20, 2011

You can echo your command into at as input:

echo "/usr/bin/php /run/this/script.php" | at 18:43