skip to Main Content

Trying to setup a Cron task that gets a file via FTP however seems to fail due to file permissions.

Code runs perfect in the browser, ie when apache is the owner, however fails when Cron runs the same page.

I’m assuming this is a directory/file permission error, if so who should I set the directory owner too for Cron jobs?

2

Answers


  1. cron jobs will run as the user that created them. More likely than a permissions error is a path error. If you’re not specifying full absolute paths to the program/script to run, and to any files you reference, you’ll likely have problems as cron won’t have the same PATH in its environment as Apache does or you do at your shell prompt.

    Login or Signup to reply.
  2. Most likely Dan’s thought is going to be your problem. However if it works from a browser you can also call the page like this:

    wget -q "http://www.domain.com/path/to/script/script.whatever" >/dev/null 2>&1
    

    if you still get errors you can remove the >/dev/null 2>&1 part & [if your email address is in the domain administrator account correctly] output, including errors should get emailed to you.

    As for the correct permissions, don’t change the default plesk ones or you will get issues with normal ftp.
    Defaults are:
    everything under httpdocs = ftpuser.psacln
    anything written by php/apache = apache.apache ~ unless you are running php as a cgi on that domain,, then they will belong to the ftp user as well.

    -sean

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search