22

I've edited my root cron tab to periodically execute a script located in a particular user's folder using this command:

sudo crontab -e

When cron runs the script, this is the output:

sh: 1: /home/user/Location/Of/Script: Permission denied

I thought that the root cron had permission to do anything. I have no issue when I manually run this script as root.

I've read in the documentation that further error info can be found here:

sudo cat /var/log/syslog

Here's what I found:

Jan 30 12:30:01 backup CRON[17702]: (CRON) info (No MTA installed, discarding output)

However, I think this is probably unrelated to the permission denied issue.

So what do I really need to do?

5
  • 3
    Can you list permissions on /home/user/Location/Of/Script? E.g. la -l /home/user/Location/Of/Script. Incidentally, you need an MTA installed for normal internal use, even if you are not sending/receiving email externally. I'm surprised your system does not have it already installed. Jan 30, 2014 at 18:50
  • 1
    This could be due to all sorts of things. Please post the output of the command @FaheemMitha requested as well as the relevant line in your crontab
    – terdon
    Jan 30, 2014 at 18:56
  • -rw-r--r-- (this was the issue) -Thank you Feb 26, 2014 at 17:17
  • You say you solved it with "-rw-r--r--" but I don't know what that is or how to use it and I have the same issue as described in this thread. Can you be a bit more specific with your solution for posterity? People like me will be really grateful for it. Thank you! Jul 8, 2016 at 22:48
  • @JohnsonJason : The issue was that the permissions on the script-file did not permit execution. Look at the accepted answer, which shows how to give the script permission to execute. Jul 10, 2016 at 3:54

1 Answer 1

34

I think that your script is not executable. So, use the following command to make it:

chmod +x /home/user/Location/Of/Script

Or, if you are not the owner of that script:

sudo chmod +x /home/user/Location/Of/Script
3
  • So for cron to run the script it must be executable, but manually as root doesn't need this flag, right? Jan 30, 2014 at 21:13
  • 1
    Depends how you run the script manually. If you run the script using ./Scipt or /home/user/Location/Of/Script it's not ok. Generally any script must to be executable. See How to run a shell script in Linux. Jan 30, 2014 at 21:28
  • That makes sense, but I really have been running this script manually the ./script way without encountering any permissions issues until I tried to cron it. Thanks for you help. Jan 30, 2014 at 21:56

You must log in to answer this question.

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