I have a bash script needs run at a specific time and found out at is pretty much does what I need to do. But the problem is I'm not sure how can I pass command line arguments to the bash script through at. Below command is what I finally ended up after looking through some other solutions.

echo "-f job.sh argument" | xargs at now + 2 minutes

But this does not work. Can anyone help me with this?

2 Answers 2


Remove xargs (and -f). at reads command from standard input if you don't use -f.

From the POSIX specification for at:

The at utility shall read commands from standard input and group them together as an at-job, to be executed at a later time.

In your case:

echo 'job.sh argument' | at now + 2 minutes

This would execute job.sh argument in two minutes.


at now + 2 minutes <<'AT_JOB'
job.sh argument

You can't pass arguments to an at job really (at -f job.sh argument ... would not work), so you must make the arguments part of the job, which both of the above variations do.

  • The OP is still missing some sort of command though Jan 23, 2020 at 18:40
  • @roaima I just spotted that. I think they want to pass the -f as if calling at with a file.
    – Kusalananda
    Jan 23, 2020 at 18:42
  • @Kusalananda I tested the command echo 'job.sh argument' | at now + 2 minutes before I posting this question, and though I get the warning I usually get when I execute script through at, the script never executes. And also it shows the time when the job gets executed (in this case 2 minutes after the current time)
    – yash
    Jan 24, 2020 at 3:51
at now + 2 minutes
/your/script -flags parameters

where I've written ^D you should use Ctrl D

Or programmatically,

echo '/your/script -flags parameters' |  at now + 2 minutes


Fri 24 Jan 12:45:18 GMT 2020

echo 'date >test.txt' | at now + 2 minutes
warning: commands will be executed using /bin/sh
job 1173 at Fri Jan 24 12:47:00 2020
  • hello @roaima unfortunately the last option doesn't execute my script in the given time
    – yash
    Jan 24, 2020 at 12:28
  • I think there must be something else happening then. Please see example in my (updated) answer. Jan 24, 2020 at 12:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .