Are There Any Cron Jobs Alternative?

前端 未结 8 2055
礼貌的吻别
礼貌的吻别 2020-12-09 19:43

Cron Jobs are closed on my server and server admin doesn\'t accept open it. Because , cron jobs slowing server etc. So, i need an alternative.

I have to run a php fi

相关标签:
8条回答
  • 2020-12-09 19:48

    Even though the question was posted a while ago, I just had the same problem but found a solution (based on Kissaki's answer, thanks!) and thought I'd post it here for anyone 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)
    
    0 讨论(0)
  • 2020-12-09 19:55

    You can do it using AWS Lambda. Using Amazon Web Services (AWS) we could move all of our cron jobs inside an EC2 Linux server. Move Your Cron Jobs to Serverless in 3 Steps: https://thenewstack.io/move-your-cron-jobs-to-serverless-in-3-steps

    0 讨论(0)
  • 2020-12-09 20:00

    Depends on your access on the box.

    PHP itself will not be able to run standalone that well. You could do a script which tries to increase it’s execution time constantly, sleeping and checking for new jobs regularly. But that is sub-optimal as you’ll have to access it via browser once, and the script would have to make sure it only runs once.

    With shell access you could run the php script on the shell, which would prevent it from being callable from public and having to run it via webbrowser.

    With shell access you could also run a program that provides a (cron) service for you. Be it a Java, Python, or other program.

    Cron jobs shouldn’t slow the server always. That depends on the job that is run. If it’s your jobs that are so expensive your admin will probably not be okay with working around the closed cron jobs and slowing the server again anyway and may take further action to prevent you from working around.

    0 讨论(0)
  • 2020-12-09 20:01

    Subscibe to a (free) web site monitoring service, and schedule your [url]/cron.php. You can have your webpage page return something meaningfull and configure the monitoring service to notify you on that response.

    0 讨论(0)
  • 2020-12-09 20:05

    If you had a lot of visitors, just write to database last time visit, and if nest time more needed time - run cron. But actually - find new hosting.

    0 讨论(0)
  • 2020-12-09 20:06

    Seems like this might be your solution - Free & Easy Cronjob Execution.

    As I get it, it's a webservice that will evoke your site URL via schedule you setup.

    Found mention about this thing here - https://stackoverflow.com/a/6853113/123618

    0 讨论(0)
提交回复
热议问题