Event Routine - PHP

Asked

Viewed 436 times

2

Hello, I would like to know how to make a routine that every Monday, run a method in my system.

Thanks

  • Dude.. your question is very good.. do you want to say without anyone having to run this application online? Just the server?

  • Exactly, @Andreicoelho

  • I found this here... http://googleweblight.com/? lite_url=http://rubsphp.blogspot.com/2010/10/tarefas-agendadas.html?m%3D1&ei=Pijtsrlc&lc=en-Br&s=1&m=958&ts=1444879723&Sig=Aponpfmeusfylq25h2xqs9p9jyix2phb9w

  • I think that solves

  • I even added it to my favorites one day I’ll need it

  • @Andreicoelho, thank you very much. But I don’t think that’s what I want

  • 1

    You need an agent with cron or similar, have a question here

Show 2 more comments

3 answers

3

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

You can type crontab -l to check scheduled tasks.

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

Format

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

  • Minutes: enter numbers from 0 to 59;

  • Hours: enter numbers from 0 to 23;

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

  • Month: enter numbers from 1 to 12;

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

  • User: is the user who 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 executed.

Example

45 19 1.15 ? * php script.php

Runs the.php script every Monday at 4:30 am.

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

Other option

It’s using javascript, every time the user updates the page, you take the day of the week, check if it’s Monday, if yes, then you make an ajax and run your php script.

-1

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

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.