CronJob

Do you need help playing, have ideas for the game or just want to talk about what's going on in the game? This is the place.

Post Reply
FoxMuldr
Posts: 1
Joined: Fri May 23, 2014 18:03 UTC

CronJob

Post by FoxMuldr » Fri May 23, 2014 18:19 UTC

I am having trouble getting my game to respond to the cronjob that calls the scheduler to update. Anyone have any insights into this?

thekabal
Posts: 100
Joined: Sat Apr 19, 2014 22:32 UTC

Re: CronJob

Post by thekabal » Sun May 25, 2014 16:52 UTC

FoxMuldr wrote:I am having trouble getting my game to respond to the cronjob that calls the scheduler to update. Anyone have any insights into this?
Yup! This is the most common issue admins face when trying to get BNT setup.

Two pieces of advice usually help the most. First, try accessing the scheduler in your browser. http://example.com/scheduler.php , and then enter the admin password. If it works, great! On to step two. If not, share the errors you get.

The rest I will quote from our fine docs/install manual in SVN today:
Contact your hosting provider, and determine which command-line web fetching program they make
available to you, and where it is located. This is to help set up a background task that will be called
every X minutes.
You can set this to any interval you want, but 5 or 6 minutes are good standard values.
This task needs to call the web page scheduler.php passing the admin password to it, eg by accessing:

http://localhost/blacknova/scheduler.ph ... h=password

On UNIX and Linux, you can achieve this by using cron to call lynx to access
the pages at specified times. Lynx is just one of many programs you can use to access the page. It
may not be available on your server, and you will need to substitute a different program. Please check
your hosting provider documentation to determine which program is available.

A sample crontab follows:

*/6 * * * * /usr/bin/lynx --dump http://localhost/blacknova/scheduler.ph ... h=password > /dev/null

A few alternatives:

*/6 * * * * /usr/bin/GET http://localhost/blacknova/scheduler.ph ... h=password > /dev/null

*/6 * * * * /usr/bin/wget "http://localhost/blacknova/scheduler.ph ... h=password" > /dev/null

Please note that your hosting provider may have these programs at a different location than /usr/bin, requiring
you to change the location to match their documentation.

You may need to alter the URL to point to your exact domain name
and path. You will also need to change the password to your admin password.

To specify how fast-paced you want the game to be, you will need to
edit the file config.php and select how many minutes you want between
different events, eg turns or port regeneration.

bluebear
Posts: 3
Joined: Wed Jun 04, 2014 08:17 UTC

Re: CronJob

Post by bluebear » Wed Jun 04, 2014 08:19 UTC

Thanks for sharing this soultions.

User avatar
TheMightyDude
Site Admin
Posts: 311
Joined: Thu Apr 17, 2014 09:15 UTC

Re: CronJob

Post by TheMightyDude » Thu Jun 12, 2014 20:10 UTC

coolmates wrote:i am getting a cannot open input file and no such file or directory errors in cron, yet the file works fine when accessed in a browser.
tried server path and direct url in cron but without success.
What command line do you have in the cron tab?

Try using the following in crontab:

Code: Select all

*/6 * * * * /usr/bin/lynx --dump http://www.cool-mates.com/bnt/scheduler.php?swordfish=ADMINPASS > /dev/null
Change ADMINPASS to your admin password.
The */6 means call that page every 6 mins.
TheMightyDude::Blacknova Development.
Development Blog YouTube Dev Channel Twitter Twitch

phpfixer
Posts: 3
Joined: Tue Apr 22, 2014 02:23 UTC

Re: CronJob

Post by phpfixer » Thu Jun 12, 2014 23:44 UTC

coolmates wrote:i am getting a cannot open input file and no such file or directory errors in cron, yet the file works fine when accessed in a browser.
tried server path and direct url in cron but without success.
Try dropping /dev/null from the cron line (it'll probably write a file to your home directory that you'll need to delete, so don't consider it fixed if it works)

Might have a permissions issue and not able to access /dev/null

thekabal
Posts: 100
Joined: Sat Apr 19, 2014 22:32 UTC

Re: CronJob

Post by thekabal » Fri Jun 13, 2014 00:55 UTC

coolmates wrote:i am getting a cannot open input file and no such file or directory errors in cron, yet the file works fine when accessed in a browser.
tried server path and direct url in cron but without success.
Two error messages: Cannot open input file (Which input file?), and no such file or directory (Which file or directory).

COPY AND PASTE the COMPLETE error message, so its not an interpretation of a summary of multiple errors, so we can help you better.

My guess? Your host doesn't have the particular program (wget/lynx/links/etc) that you tried in your crontab. The error message should include the line you used in cron, so we can try to help.

Also useful? Which hosting company? What *distribution* of Linux are they running? If you don't mind sharing, what is the link to setup_info.php?

Help us, help you.

thekabal
Posts: 100
Joined: Sat Apr 19, 2014 22:32 UTC

Re: CronJob

Post by thekabal » Fri Jun 13, 2014 01:49 UTC

To help further, I've created a script that can help determine which tool you should use from cronjobs.

https://gist.github.com/anonymous/09c72cf93fe162d50f40

Sample result..
You can use any of the following in your crontab:
/usr/bin/curl
/usr/local/bin/wget
Then you can put that into your cron, and you should have success.

I will work to include this in the next version of setup_info.php for BNT.

thekabal
Posts: 100
Joined: Sat Apr 19, 2014 22:32 UTC

Re: CronJob

Post by thekabal » Sat Jun 14, 2014 17:02 UTC

coolmates wrote:thanks everyone for your kindness. the grabber worked like a charm, and as a result, so is the cronjob.
To help us improve, can you share what the working solution was for your server?

Thanks!

Post Reply