Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a command at a specific time

Tags:

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,

like image 499
Eamorr Avatar asked Apr 20 '11 17:04

Eamorr


People also ask

What should I do to run a script on specific time without cron?

the_main_thing is the command or script you want to run periodically. The purpose of [[ $0 = /* ]] && script=$0 || script=$PWD/$0 is to get the absolute path of the current script itself.

How will you schedule a script to run once a day at 3am on a Linux system?

cron Special Characters. cron expressions typically contain one or more special characters that help us with scheduling tasks. Here, by using an asterisk in the last three fields (1-31 days, 1-12 months, all days of the week), our backups.sh script will run every day at 3 pm.


1 Answers

You can echo your command into at as input:

echo "/usr/bin/php /run/this/script.php" | at 18:43 
like image 151
Michael Berkowski Avatar answered Oct 28 '22 06:10

Michael Berkowski