Cron job: Permission Denied error

I'm trying to create a test cron job which calls a php file. I kind of understand the info in Linode's cron documentation:

I can edit a crontab file using:

crontab -e

I can create a job which runs every ten minutes:

*/10 * * * * /srv/www/mysite.com/public_html/myfolder/cron.php

But the email output (every ten minutes) is:

/bin/sh: /srv/www/mysite.com/public_html/myfolder/cron.php: Permission denied

What am I missing?

Using Ubuntu 10.04 LTS stackscript; a test wordpress install seems to be working normally

6 Replies

You're trying to execute it now. Depending on the type of script you're gonna want to do either this or this:

*/10 * * * * /usr/bin/php  srv/www/mysite.com/public_html/myfolder/cron.php 

or

 */10 * * * * cd /srv/www/mysite.com/public_html/myfolder/ && /usr/bin/php cron.php

that changes my error to this:

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

You don't have php cli loaded. It many times is an additional package that needs to be loaded.

apt-get -y install php5-cli

Thanks! – installing php5-cli got the cron job to successfully trigger my target php.file.

Apparently the LAMP StackScript I was using didn't have this step in it.

PHP shell scripts are generally not a typical scenario, so they wouldn't be.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct