|
|
Wget Help Needed Please.
|
|
|
|
Fresh-Faced Recruit
Join Date: Feb 2006
Status:
Offline
|
|
well, i have only been learning about linux, unix and shells for a few days.
For my online game to work, i need run a file each 10 seconds. Running that file will update mysql data, causing my online game to "tick". This adds resources and fights battles in game.
I know that i need to use a bakground process, a wget commad.
Code:
#!/bin/bash
while true; do
wget my_url/tick.php
sleep 10
done
exit 0
That keeps the process running, whilst i am logged in to putty.
I want to exit my SSH program, and leave that process running for ever. Please help me!
Thanks, Kiran
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally Posted by Kiran
Code:
#!/bin/bash
while true; do
wget my_url/tick.php
sleep 10
done
exit 0
That keeps the process running, whilst i am logged in to putty.
I want to exit my SSH program, and leave that process running for ever. Please help me!
There are probably a hundred better ways to do this, but here's the first thing that popped in my head: say your script lived in a file called "tick.sh," you could run it like this to make it truly background: nohup ./tick.sh &.
This would allow you to exit your SSH session and have the script run in the background. To kill it later, use ps -auxx | grep tick (or something to find the process number), and then kill it.
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Dec 2005
Status:
Offline
|
|
The 'watch' command is what you need, I think. It runs a command at a specified interval. I.e.
watch -n 10 'wget my_url/tick.php'
As an alternative to the above, if your remote server accepts cron jobs, investigate cron.
|
iMac G5 17in 2.0GHz , 512MB RAM , ATI Radeon 9600 128MB , Mac OS X Tiger / FCE HD / Soundtrack Pro
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|