Cron Job for Ubunto LEMP Stack

April 27, 2016 1.8k views
Getting Started LEMP PHP

Simple cron job php script

$dir = '/usr/share/nginx/html/mobile-api/LoveIsTheAnswer';
if (!file_exists($dir)) {
    mkdir($dir, 0700, true);

Location: /usr/share/nginx/html/mobile-api/create.php


1 * * * * /sur/share/nginx/html/mobile-api/create.php

My questions are.

  1. Any third party to install before running the cron job?
  2. The cron job does not working. Any missing code on the crontab?
  3. What crontab command to use in executing the create.php to test in putty before setting up to crontab file.

Thank you.

1 Answer

replace cron with this:

* * * * * /usr/bin/php -q /usr/share/nginx/html/mobile-api/create.php

It’s not a PHP CLI script, so you need to tell it the interpriter to use, and you misspelled usr

Also, I don’t know what you’ve installed, so I can’t say what else you’ll need.

Have another answer? Share your knowledge.