Event Routine - PHP

2

Hello, I would like to know how to do a routine that every Monday, I used a method on my system.

Thanks

    
asked by anonymous 15.10.2015 / 05:14

3 answers

3

You need to use crontab (Linux) and cronjob (Windows).

  

You can type crontab -l to check the scheduled tasks.

     

You can type crontab -e to add a new rule to a   new task.

Format

[minutes] [hours] [days of the month] [month] [days of the week] [user] [command]

  • Minutes: Report numbers from 0 to 59;

  • Hours: Report numbers from 0 to 23;

  • Days of the month: Report numbers from 0 to 31;

  • Month: Report numbers from 1 to 12;

  • Days of the week: report numbers from 0 to 7;

  • User: is the user that will execute the command (it is not necessary to specify it if the user's own file is used);

  • Command: The task that must be performed.

Example

45 19 1.15 * * php script.php

Run the script.php every Monday at 4:30.

In your case, just put the code that is inside your method, inside script.php .

Another option

You can use javascript, every time you refresh the page, you get the day of the week, check if it's Monday, if so, then you do an ajax and run your php script.

    
15.10.2015 / 15:41
-1

If your routine is in PHP or Linux shell, you can include a Cronjob on the server to run at the desired time.

    
15.10.2015 / 13:13
-1

You can do this with a cron job. If you are using a hosting with cPanel, the following link will guide you with ease: link

    
15.10.2015 / 15:28