Simple cron job php script

<?php
$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

Crontab

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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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.

Submit an Answer