2

This might seem like just another basic cron question, but I cannot figure this one out:

@hourly "/usr/bin/php /usr/local/bin/notify.sh"

I migrated a bunch of stuff from one server to another and was able to get most things operating smoothly after some work, and now I'm putting out the fires.

I'm getting this email every hour, when the following cron job is supposed to run:

/bin/sh: 1: /usr/bin/php /usr/local/bin/notify.sh: not found

Typically, not found is caused by PATH not being there (an issue with cron jobs), but I am providing the full path for both PHP and the script. The script runs as root, and interactively, I can run the script.

The script has 755 permissions, just to be safe (anyone can read or execute), so the permissions are not the issue.

I can manually run the script and the script that it calls so I have no idea where this "Not found" is coming from.

Nothing suspicious in the cron log, other than this ran.

This worked properly on the old server.

Is there some other factor likely in play here, or how might I try to trace the cause of this issue?

1
  • Well, you don't have a command called notify.sh in the directory /usr/bin/php /usr/local/bin, do you? – Kusalananda Jun 24 at 12:17
5

The entry

@hourly "/usr/bin/php /usr/local/bin/notify.sh"

passes /usr/bin/php /usr/local/bin/notify.sh to /bin/sh -c as a single argument. That's why the error message is

/bin/sh: 1: /usr/bin/php /usr/local/bin/notify.sh: not found

rather than either of

/bin/sh: 1: /usr/bin/php: not found

Could not open input file: /usr/local/bin/notify.sh

To pass the program /usr/bin/php and its filename argument /usr/local/bin/notify.sh separately, remove the quoting:

@hourly /usr/bin/php /usr/local/bin/notify.sh
1
  • This indeed solves the issue - it's strange that it worked this way on the old server, though. The old one was Debian 9 as opposed to 10, though I can't think how that would make any difference... – InterLinked Jun 24 at 13:08

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.