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?

  • 2
    Just put /path/to/script argument in another script, and call that script instead. – daisy Oct 25 '12 at 0:57
  • 1
    That pretty much defeats the purpose of having arguments in the shell script. Thanks though! – Elmer Oct 25 '12 at 14:46

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

echo /path/to/script argument | at 17:45

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

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
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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