Jump to content

How do I...


Karaethon
 Share

Recommended Posts

I know that cron can run a script automatically at scheduled intervals but I have no knowledge of how to set this up. Both the cron AND the script. I can learn, obviously, but I have a question before diving in. Can I trigger an unsceduled run of the script from another script? Specifically, I have in mysql a database of number puzzles, the script will check the number of unsolved and generate new ones as needed to keep the number near the planned 1000 point. but if there is a surge of solves I want other script (user interacting script) to trigger the other script if the number drops to 100 or less. I don't want the user script hanging while puzzles are generated so i need to trigger the housekeeper script outside the userscript thread.

Link to comment
Share on other sites

If you read the documentation you will find out that cron jobs are basically just scheduled CLI calls. So if you can run that script via cron you can mostly run it via CLI at any time (at least you should test this anyway). At worst an

include 'filename.php'

will run that script.

Edited by chhorn
Link to comment
Share on other sites

First of all - who is your host?  You?  Or do you pay for some shared hosting?  With the latter the cron question is usually solved since most providers include cron abilities in their package to you.  With their (cpanel?) screen you name the script to be run and setup how often you want it to run.  Within your script - a php script - you have to place a simple hashbang(?) line (which your host will define for you) at the top to allow the cron job to run it and then design your script to run without any console/client output.  It runs in the background but has full access to your db and the php toolset so that you can do anything you want.  Therefore you could just schedule it to run hourly (?) and have it check the results in your db and from that do whatever it takes to produce more puzzles or whatever you want.

Hope this helps.

Link to comment
Share on other sites

Hmm, ok.... Thanks I have never used cron before except what the host or premade site used, I don't know how to make my own. But NotionCommotion pointed out something I was too close to see... Everytime a puzzle is solved run the generator. facepalm.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.