Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RE:Those a CRON Substitute Script exist???

Status
Not open for further replies.

mericardo

MIS
Feb 12, 2001
5
US
Howdie,

I've been following the Q&A in this forum and I've seen some great answers. It's always educational reading. Now I find myself with a question and I think this is the perfect forum for it.

My current webpage is on a shared server and my ISP does not allow CRON (scheduled jobs that run automatically) jobs to be run on the server because of previosly experienced problems. Does anyone know a script or method in Perl that can achieve the same thing?

Basically, I have a weather program that you can subscribe to and it will send you an e-mail of the weather in your selected area on a daily basis. The normal way to run the script job is using the UNIX CRON function, but as I stated above my ISP doesn't offer that functionality. I'm looking for a way, using Perl, to create a script that will check the current time and run another script based on a pre-established time selection.

I've seen you guys handle some pretty tough questions, any ideas for me?

Thanks in advance.

Marc
 
sure... it's a bit less efficient, but:[tt]
while (1) {
sleep (24*60*60);
&weather_subroutine;
}

sub weather_subroutine { .... }[/tt]


when you call this, call it[tt]
perl weatherscript.pl &[/tt]

so it runs in the background. then 'nice' it to have the lowest priority while still running (well, you don't have to). this will assume, though, that you're always logged in. this is just a guess. i'll try it out and report back if it works for me. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Stillflame,

Thanks for your quick response. I'll also play with it to see if it does the trick.

Regards,
Marc
 
the & do send the process to the background-> Yes!
but when I tried to logout, it tell me that I have job running, how could I leave a script in background even after logout?

Note my perl script takes a command line parameter-
Code:
perl mainProcessor.pl myConfig.cfg &

 
If your ISP will not let you run a cron job it is VERY unlikely they will allow you to run a background job, since that takes up even more resources. Somewhere I saw a script that launches another program whenever a certain web page was loaded (sorta like a counter script, but different) that was intended for this purpose, but the BIG drawback was that the web page had to get hit frequently and regularly for it to work.

My suggestion: get another ISP.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
You *could* write your script so that it uses fork() to make a copy of itself and then exits. The copy then continues. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Is there not like a command line thing I could type in together with the & to get the script running even After logout? I think the & means run as new process (fork?)?? but if I then logout I get warning saying 'You have job running'
 
It doesn't matter whether you fork, knife, spoon, or whatever. If the ISP has set things up so that you cannot run a background job, or so that your background jobs cannot continue once you log out, there is no way around it.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
try the nohup command mericardo Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
hypothetical: could you write a script to logon, either as nobody if there's no password to it, or into your account, if the server allows multiple instances of a single user being logged on? in either of those cases, you could just have the script logged on at all times, maybe touching a file every now and then to reassure the server that it's active... i don't really know if this would work, it's just an idea. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Howdie all,

I discovered that CRON is controlled by the Web Admin and the hosting company I was using refused to give me authorization. Since CRON wasn't available to me, there was nothing PERL could do for me. Since them I'v switched hosting companies and can now run CRON jobs on my PERL scripts. I wanted to thank everybody for there help.

Regards,
Marc
 
On UNIX, &quot;nohup <script> &&quot; will run a process in the background and will not die when you log out - works great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top