Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
How to run a cron job?

Server: nginx/0.8.54
OS: Ubuntu 11.04
Host: Rackspace UK Cloud
Access: Full Root etc

I have a PHP script in my cloud server:

/var/www/www.site.com/web/cron_tasks.hash/report.php

I want to run this task every day just once - the time does not matter. It would be ideal if I could run it in the morning.

Also how can I view a list of already listed cron jobs? Sorry but I can't find an Nginx server question for this.

share|improve this question

marked as duplicate by Bart De Vos, MDMarra, Ward, rnxrx, Michael Hampton Sep 15 '12 at 22:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I think normal SSH commands will work regardless. Nginx btw is the server OS - it is a web server and not the server itself. –  M1th Sep 14 '12 at 8:55

2 Answers 2

up vote 4 down vote accepted
  • Open Nginx in SuperUser mode

    sudo su

  • View Cron Jobs

    crontab -l

  • Edit Cron Jobs

    crontab -e

  • Daily Cron Jobs

    # Run this script at 12 midnight once a day

    5 0 * * * /var/www/www.site.com/web/cron_tasks.hash/report.php

share|improve this answer
    
This presupposes that the report.php has a suitable shebang which isn't normally the case. –  Iain Sep 15 '12 at 21:39

This really has nothing to do with nginx.

You can use the crontab(1) command to maintain user crontab(5) files e.g.

crontab -u root -l 

would list the entries in root's crontab. You would need to do this for each useron your system to get a complete list.

There will also be a /etc/crontab file that will contain system cron commands. The directories /etc/cron.* will contain additional commands too.

You'll probably find this documentation usefull at this point.

To run your command add an entry to a suitablBe user crontab like so

10 4 * * * /usr/bin/php -f /var/www/www.site.com/web/cron_tasks.hash/report.php

Which will run the command at 04:10 every day

share|improve this answer

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