Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder what read / write permissions should I set on my cron files (php files) so they can be executed only by our server.

We're using CentOS 5.9 - 64bit and cPanel / WHM + Apache.


share|improve this question
@MarkC.Wallace LMGTFY is discouraged – LamonteCristo Feb 14 '13 at 18:47
up vote 1 down vote accepted

Are these cron files going to be executed by root or are they going to be executed by a specific user such as apache? Normally I either log into a specific user (bob) and then run "crontab -e" to edit Bob's crontab. For these cron jobs to run, you just need to ensure that bob has execute writes to the script in question. However if these are going to be more administrative scripts for apache or root, then you may want to just put them in "/etc/crontab". From here, you can set how often the script runs and what user should run the script. Then just be sure whatever user you set to run the script has the appropriate rights to execute it. So if only root needs to run it, just chown the file to root only and you can 744 it so only root can execute the file.

share|improve this answer

Typically your apache webserver will run as www-data or apache or similar (look at top to see which user is running it). So if the files need to be executable by the webserver make them

sudo chown www-data:www-data somefile.php sudo chmod 770 somefile.php

This will make somefile.php belong to the www-data user and group with read/write/execute permissions only for the www-data user or members of the www-data group.

Then make the crontab as crontab -e -u www-data. I would hesitate making them owned by root (as then the php file will run as root when executed).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.