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 have a shell script that accepts an argument and uses that in the script. So to run the script I type /path/to/script argument

The problem is when trying to setup that file to run using the at utility. I have tried

at -f /path/to/script argument 17:45

at -f '/path/to/script argument' 17:45

but neither of these options work. First one receives a syntax error and the second says no such file Any suggestions?

share|improve this question
Just put /path/to/script argument in another script, and call that script instead. – warl0ck Oct 25 '12 at 0:57
That pretty much defeats the purpose of having arguments in the shell script. Thanks though! – Elmer Oct 25 '12 at 14:46
up vote 6 down vote accepted

Since at defaults to reading from standard input, you can just do this:

echo /path/to/script argument | at 17:45
share|improve this answer

I would recommend following the advice of @warl0ck in the general case -- create a new script, e.g. /path/to/newscript:

 /path/to/script argument

and then run that using at:

 at -f /path/to/newscript 17:45

This makes it easy to adjust whatever arguments are needed, run multiple commands, etc.

Alternatively, for occasional or one-off use, you can just run at with the chosen time, and then enter whatever command(s) you need on standard input; hit ctrl-D to end:

 myhost# at 17:45
 /path/to/script argument
 Job 1 will be executed using /bin/sh
share|improve this answer

I had this issue too and I solved it by using EOF.

This is starting a ssh connection to sshserverhost that executes test.sh with parameter $HOSTNAME on the remote server (sshserverhost).

at now + 1 minutes <<EOF
ssh -t sshserverhost 'bash -s' <~/test.sh $HOSTNAME
share|improve this answer
Is this an answer to the OP's question, or are you saying you have the issue too... – eyoung100 Oct 20 '14 at 19:17

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.