Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 have a php file located at, let's say, for example:


This file is not publicly available (no virtual host is running in that folder, but apache is installed). I need to execute this file every minute every day.

I know I can open crontab with crontab -e, but I'm not sure what exactly should I write to the file so that what I need to do works.

Any help, please?

share|improve this question
up vote 0 down vote accepted

run crontab -e and add line:

* * * * * /usr/bin/php -f /data/web/process.php 2>&1 >> /path/to/output/file.log

Before you do that, make sure that /usr/bin/php -f /data/web/process.php does what you want. Also note, that cron will run it as same user who called crontab -e, so if you run it as user rimmer it will run as rimmer, if as a root, it will run as a root.

if you want it to be executed as apache user, do:

sudo -u www-data crontab -e

assuming www-data is your apache user. You can also create a file /etc/cron.d/my-php-job.

Make sure no bad guys can edit /data/web/process.php file and review that file carefully. I would make this file root owned and with 644 permission. Do not make it apache user owned and writable.

share|improve this answer

Try the following:

/path/to/php -f /data/web/process.php

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.