Cron Job for Ubunto LEMP Stack

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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.