I am trying to run an 'at' job. The job is in ~/mydir/first.sh. It executes second.sh using (sh second.sh) which is in the same directory. I get an error saying that the file is not found.

This is very unusual as I am doing the exact same thing on another linux laptop and have no issues.

  • 1
    It's difficult to debug this as you don't say anything about what you have done. Please show exactly what commands you are issuing and exactly what the error is that you are getting.
    – Kusalananda
    Commented Aug 31, 2021 at 13:40
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Sep 4, 2021 at 23:19

2 Answers 2


When creating an at job, the system creates a file with a copy of your current shell environment. This includes the PATH variable. Unless PATH contains '.' as one of the entries, then the at job will fail, just like if you tried to run it manually.

You can see what the system created where there will be a file under /var/spool/atjobs/.

  • Actually, ~/mydir/ should be in your path, or the script cd's to that directory and '.' is in your path.
    – Bib
    Commented Aug 31, 2021 at 17:06
  • Since the user is executing second.sh using sh second.sh, the PATH variable doesn't even enter into the equation. The only thing that matters is what the current working directory is. With at, the directory from which at was invoked will be the working directory of the job.
    – Kusalananda
    Commented Aug 31, 2021 at 17:49

Try using absolute path references in your scripts, I find that this is typically needed for cronjobs, and I assume the same applies to at.

I can’t add this as a comment, my reputation is not high enough.

You must log in to answer this question.

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