Bash – Scheduling command/script by specifying the exact second

bashcommand linescriptingshell

I'm using bash and wondering how I can execute a command/script at a later specified time, with the accuracy of a second?

I read the man page for the at-command, but as far as I could understand it's only possible specify minutes (and not seconds). Right now I first use at and then sleep to get it to execute the right second. To demonstrate, if I would like to run my_script.sh at 22.21.05 I would do:

echo "sleep 5; my_script.sh" | at 22.21

But it would be much nicer to have a command with it built in. Something like at 22.21.05.

Best Answer

I don't believe that this is possible. cron is only granular down to the minute and the at utility hooks into it to do it's work. I think you have the right solution--sleeping for x seconds before executing.