Is Cron the only method to run scheduled tasks?

Is cron (or its derivatives) the only method for performing scheduled programming tasks? For instance:

  • Credit card customer customers 3 days before X
  • Send e-mail 6 hours from the time
  • Run xyz every hour

Is there any good resource / books to teach how to implement these functions in their pure form (python, ruby ​​(or ROR), python)?

My current dirty method is to run a script shell in CronTab every minute to check if certain tasks should be performed. I don’t really like it. I prefer a method in which I can programmatically implement scheduled tasks.

+4
source share
4 answers

For python you can use celery

For example, executing a command every hour would look like this:

from celery.task.schedules import crontab from celery.decorators import periodic_task @periodic_task(run_every=crontab(hour=3)) def every_three_hour(): print("This runs every three hour") 

And after three hours you will see:

 from datetime import datetime YourTask.apply_async(args=[some, args, here], eta=datetime.now()+datetime.timedelta(hours=3)) 
+3
source

at may be more appropriate if you want to plan one-time tasks overnight at a specified time in the future.

+1
source

No, you set the schedule task using linux, we did something like this

 if (strtoupper(substr(php_uname(), 0, 3)) === 'WIN') { // This is for Windows $cmd = PHP_PATH . " " . PATH_CLASS . "/Cron/somecron.php"; pclose(popen("start /B ". $cmd, "r")); unset($_SESSION['something']); } else { //This is for Linux exec("php " . PATH_CLASS . "/Cron/somecron.php > /dev/null &"); unset($_SESSION['something']); } 
0
source

I would suggest using Ruby / ROR delayed_job , more details here .

Very easy to configure and most important is an active project, which is the weapon of choice for most of the Rubiest that I know :)

0
source

Source: https://habr.com/ru/post/1479909/


All Articles