Sudo command not working with cron job.

Hello,

I have written a script that has a sudo command to change file permissions within it.

When I run the script manually, the sudo command inside of it works fine.

When the script is run through crontab I get the error "cron: not found".

It the same user profile that I am using to run the script manually that is running the cron jobs.

Any ideas on how to fix this would be greatly appreiciated.

Thanks.

are you able to provide details of the script you're running via cron?

In general 'sudo' in a cron script is a bad idea. Also, in your scripts are you using the full path/command? You should do that. Are you cable to just install the job under root?

Sounds like the "Cron Error Number 1" to me: read here how to get over that.

I hope this helps.

bakunin

What details would you nedd?

The jist of it is it uses the sudo command to change the permissions of a file, making it writable, then empties the contents of said file (cat > /dev/null).

So without the sudo command, the file cannot be emptied.

Yes, the full path is being used.

No, I cannot install it under root.

So to see if this is the case, I need to copy the "PATH=" variable from the env file into my script?

Sorry if this was answered in the link you supplied, but I am a beginner with unix and am not sure what the resolution was that was provided.

Thanks.