3

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.

1
  • 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, 2012 at 8:55

2 Answers 2

5
  • 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

2
  • This presupposes that the report.php has a suitable shebang which isn't normally the case.
    – user9517
    Sep 15, 2012 at 21:39
  • Hi, may i know what does 5 0 * * * refers to?
    – Slay
    May 19, 2016 at 10:12
1

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

Not the answer you're looking for? Browse other questions tagged .