Cron job gives permission error on execution

August 1, 2015 3.6k views
Linux Commands Ubuntu LEMP PHP

I am running a tracker (CPVLab) hosted on a Lemp Stack
The site works fine but there is a problem with a cron job. When the cron job executes I get an error:

2015/08/01 07:00:04 [error] 1303#0: *605 FastCGI sent in stderr: “PHP message: PHP Warning: unlink(/var/www/ Permission denied in /var/www/ on line 0” while reading response header from upstream, client:, server:, request: “GET /cron-wurfl.php HTTP/1.1”, upstream: “fastcgi://”, host: “”

I set up the cron job using crontab -e as root, no other errors present but I did have issues with ionCube leaders to start with.
Can anyone help please.

  • There seems to be two pieces that I can gather from your query!

    1.) Permissions error while ruinning CRON:
    It seens that cache folder in your installation is not set with 777 permissions. Generally in popular CMS distributions, this is how it works!

    2.) Issues with ionCube Loaders:
    There is a easy to implement ionCube article. Once done, you should run this file. It will give you another INI file and also tell you where to place it (depending on your installation of PHP FCGI).

    Just an observation, it may so happen that once you resolve your ionCube Loader issue, your first piece may get resolved automatically!

    Let’s see how it goes!

  • Hi
    Thanks for reply, the cache folder is set to 777 and I think the ionCube loader issue is solved but i still have the the error.
    Could it be an ownership issue?

2 Answers

Are you using wget to request the file on crontab?

If so it doesn’t matter if cron is setup as root or any other user as it is Nginx and PHP-FPM executing the file as the web user.

Try changing the ownership of the whole directory:

chown -R www-data:www-data /var/www/

BINGO problem solved!
Thanks for the answers, much appreciated

Have another answer? Share your knowledge.