-2

I'm trying to add a cron in Ubuntu. This cron will execute a function in PHP for every 4 month.

How could I do that?

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
Dimas
  • 1
  • 1
  • `crontab -e` opens up the crontab editor (see `man crontab` for more info) then just add an entry for `php your_file.php` to happen every 4 months – mike510a Feb 27 '17 at 04:42

2 Answers2

1

First, Login to UNIX/Linux system.

Type the following command to enter cronjob:

$ crontab -e

Each cronjob has the following syntax:

# +---------------- minute (0 - 59)
# |  +------------- hour (0 - 23)
# |  |  +---------- day of month (1 - 31)
# |  |  |  +------- month (1 - 12)
# |  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
# |  |  |  |  |
  *  *  *  *  *  command to be executed

To get crontab to run a task every 10 minutes you could type as follow:

*/10 * * * * /path/to/command

OR

*/10 * * * * /path/to/script

Reference

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
0

Starting to Use Cron

To use cron for tasks meant to run only for your user profile, add entries to your own user's crontab file. To edit the crontab file enter:

crontab -e

Add below Cron Line

30 03 01 Jan,Apr,Jul,Oct * File Path
Sujal Patel
  • 2,444
  • 1
  • 19
  • 38
  • thank you for ur respons sir, but i cant make it to execute the function in the php file, how could i specify the function inside the php file? – Dimas Feb 27 '17 at 06:43
  • that's a complete different question. You asked how to call a PHP-Script within a cronjob and this is your answer. We can't tell you how to call your function, you didn't even provide any code. – DasSaffe Feb 27 '17 at 08:53