Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to perform a one-liner using at.

Basically, I want to send an SMS at some point in the future.

Here's my command to send an SMS:

php -r 'include_once("/home/eamorr/open/open.ie/www/newsite/ajax/constants.php");sendCentralSMS("08574930418","hi");'

The above works great! I receive my sms in a couple of seconds.

Now, how can I get at to run this command in future?

I tried

php -r 'include_once("/home/eamorr/open/open.ie/www/newsite/ajax/constants.php");sendCentralSMS("08574930418","hi");' | at now + 2 minutes

But this sends my command immediately! I want to send the message in 2 minutes' time!

share|improve this question
up vote 5 down vote accepted

Because that's not how the at command works. at takes the command in via STDIN. What you're doing above is running the script and giving its output (if there is any) to at.

This is the functional equivalent of what you're doing:

echo hey | at now + 1 minute

Since echo hey prints out just the word "hey" the word "hey" is all I'm giving at to execute one minute in the future. You probably want to echo the full php command to at instead of running it yourself. In my example:

echo "echo hey" | at now + 1 minute


As @Gnouc pointed out, you also had a typo in your at spec. You have to say "now" so it knows what time you're adding 1 minute to.

share|improve this answer
Hi, I'm not sure what you mean. Is there a workaround that you can think of? Thank you, – Eamorr Jul 25 '14 at 19:13
updated my answer – Bratchley Jul 25 '14 at 19:16
Totally confused for a moment there... But I got it to work! Yippee! (Just updating the OP now) – Eamorr Jul 25 '14 at 19:24

You have an error in your syntax:

php -r 'include_once("/home/eamorr/open/open.ie/www/newsite/ajax/constants.php");sendCentralSMS("08574930418","hi");' |
at now + 2 minutes

From man at:

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.

You should wrap your php command in a shell script, then execute it.

$ cat sms.sh

/usr/bin/php -r 'include_once("/home/eamorr/open/open.ie/www/newsite/ajax/constants.php");sendCentralSMS("08574930418","hi");'


$ at -f sms.sh now + 2 minutes
share|improve this answer
I really didn't want to have to create a load of files. This thing is going to be called a lot and I don't want file conflicts, etc. – Eamorr Jul 25 '14 at 19:25

If you are just concerned with sending the message after 2 minutes irrespective of the approach, I would suggest using sleep.

( sleep 120 ;  php -r 'include_once("/home/eamorr/open/open.ie/www/newsite
/ajax/constants.php");sendCentralSMS("08574930418","hi");' )
share|improve this answer
Maybe. What happens if the server falls over? Do I lose all my notifications? Some are set to weeks/months in advance. Does at preserve scheduled tasks on restart? – Eamorr Jul 25 '14 at 19:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.