Are there any alternatives for working in Cron?

Cron jobs are closed on my server and the server administrator is not accepting it. Because, cron slows down the server, etc. So I need an alternative.

I need to run a php file ( cron.php ) every 2 minutes.

So how can I do this?

+8
php cron jobs
source share
8 answers

Although the question was posted some time ago, I had the same problem, but I found a solution (based on Kissaki's answer , thanks!) And thought d post it here for those who are still looking for a possible solution.

Prerequisites:

  • SSH Access
  • Python

Code (python):

from subprocess import call import time while True: call(["php","cron.php"]) time.sleep(120) 
+7
source share

Depends on your access to the field.

PHP itself will not be able to work autonomously. You can make a script that constantly tries to increase execution time, sleep, and regularly check for new tasks. But this is not optimal, since you have to access it through the browser once, and the script will need to make sure that it works only once.

With access to the shell, you can run the php script in the shell, which would prevent it from being publicly accessible and need to run it through the webbrowser.

With access to the shell, you can also run a program that provides you a service (cron). Be it Java, Python or another program.

Cron operations should not slow down the server. It depends on the work performed. If your workplaces are so expensive that your administrator will probably not work properly with cron closed jobs and slow down the server in any case, and may take further action to prevent you from working.

+2
source share

Calibrate (for free) the website monitoring service and assign your [url] /cron.php. You can return the page of your web page, something meaningful, and set up a monitoring service to notify you of this answer.

+1
source share

It seems like this might be your solution - Free Cronjob.

As I understand it, this is a web service that will call the URL of your site according to the schedule that you configure.

This was mentioned here - stack overflow.site/questions/432598 / ...

0
source share

Just an addition to the Answers. A rare scenario.

If your application often performs a lot of database operations, you can maintain a separate table in which one column will serve as a measure for running the script. Example as below

Table CRON_RUN

 last_run ---------- 12-09-2018 11:55:12 (dd-mm-yyyy H:M:S) 

Now in your application, you can check every time such frequent operations with the database occur, and check whether the date last_run and the current date x have a difference. X is the time difference when you want to run the script. 2 minutes in your case. In addition, if the difference is greater than or equal to 2 minutes, the update statement will be run to update the last_run column with the current date and time, and your cron.php script will be the next statement.

0
source share

You can do this with AWS Lambda. Using Amazon Web Services (AWS), we can move all our cron jobs to the Linux EC2 server. Move your Cron jobs to a serverless process in 3 steps: [ https://thenewstack.io/move-your-cron-jobs-to-serverless-in-3-steps/†[1]

0
source share

There are several alternatives to Cron for Linux. Like,

  1. Anacron - Anacron is a periodic command scheduler, just like cron. The only difference is that it does not require your computer to work continuously.

  2. fcron - Fcron is the best of cron and anacron. It does not require your computer to run 24 Γ— 7, and it can work with tasks on an hourly or minute basis.

  3. Hcron

  4. Jobber etc.

For further reading, refer to this article .

0
source share

If you had a lot of visitors, just write to the database last time, and if the socket time is longer, cron will need it. But actually - find a new hosting.

-2
source share

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


All Articles