Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Wget Help Needed Please.

Wget Help Needed Please.
Thread Tools
Kiran
Fresh-Faced Recruit
Join Date: Feb 2006
Status: Offline
Reply With Quote
Feb 20, 2006, 02:04 PM
 
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
     
[APi]TheMan
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Feb 20, 2006, 08:49 PM
 
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"

     
Baryon
Fresh-Faced Recruit
Join Date: Dec 2005
Status: Offline
Reply With Quote
Feb 21, 2006, 01:11 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:55 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,