CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Almost Finished! Need Help!

 



xcom
stranger

May 31, 2001, 7:31 PM

Post #1 of 13 (4029 views)
Almost Finished! Need Help! Can't Post

Im just about finished with my first major script! (an entire affiliate program!) and am totally stuck on the last thing I need to do! (go figure!)
The idea of what I want to do is simply to have stats update only once every half hour. Stats are already being written to a temp file waiting to be transfered at the half hour mark to the stats log that the stats page reads from. I already got the copy to log file from the temp file written as well. My problem is I dont know how to make the transfer automaticallly every half hour. My idea so far was everytime the out.cgi (scipt which writes to temp stats) is executed,it would check to see if it was time to write the temp stats to the real log file. I have gone over and over this and dont know what to do! And its the last thing I need to complete this script! Part of the problem with doing it the way I explained (at least the way I was thinking) is that if the script isnt executed (from a click) at the time the stats need to be written to the log file from the temp file,then that update will be missed! I just cant seem to figure this out! Anybody have an idea for me?!?!

Thanks,
...xcom



Jasmine
Administrator / Moderator

May 31, 2001, 7:39 PM

Post #2 of 13 (4027 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

If you're on a *nix server, cron will do the trick. Check out this simple cron tutorial.



xcom
stranger

May 31, 2001, 8:53 PM

Post #3 of 13 (4025 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Thats it??
I knew about crontab,but didnt really know anything about it. Geez...thats super simple then!
So,i just put this:
"0,30" * * * * * /full/path/to/cgi-bin/update.cgi
into a text file,name it something like cronfile.txt,upload it and type crontab cronfile.txt and that it?
Does the text file need anything else? like the shebang in a cgi script? Does it matter where its uploaded to and crontabbed? Like,does it need to be in cgi-bin or what?
Thanks for your help Jasmine!



Jasmine
Administrator / Moderator

Jun 1, 2001, 6:29 AM

Post #4 of 13 (4013 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post


In Reply To
So,i just put this:
"0,30" * * * * * /full/path/to/cgi-bin/update.cgi
into a text file,name it something like cronfile.txt,upload it and type crontab cronfile.txt and that it?

Actually, that would be


Code
0 30 * * * * /full/path/to/update.cgi


In Reply To
Does the text file need anything else?

No, that's all it needs.


In Reply To
like the shebang in a cgi script?

Your update.cgi should have the shebang in it, so any other shebang isn't necessary. One important note... if your update.cgi is requiring other files, you should be sure to use full paths to the files in your require statement.


Code
# wrong 
require "mylib.pl";

#right
require "full/path/to/mylib.pl";

This is needed because cron is invoking your program from a different directory.


In Reply To
Does it matter where its uploaded to and crontabbed? Like,does it need to be in cgi-bin or what?

No. Cron is like the ls and pwd commands in that they're available anywhere within your server space.

It's extremely important to note that cron will not work unless your server administrator gives you cron access. Some do, some don't. Those that do may restrict your number of processes in a day.

Hope this helps!



xcom
stranger

Jun 1, 2001, 3:48 PM

Post #5 of 13 (4000 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Thanks Jasmine.
I do have cron access.
Thanks for clearing that up for me!
That certainly simplifies everything being able to use cron!
Well...I guess that means Im finished and ready to go! Thanks to everyone for their help in this!



xcom
stranger

Jun 3, 2001, 9:30 PM

Post #6 of 13 (3985 views)
Errrr......... [In reply to] Can't Post

Jasmine...are you around???

I am having trouble. Ive got my program uploaded to a new server. everything reconfigured and working smoothly. cool!.....
Then...i get to the cron part.
I have a file name cronfile.txt,which contains the following:
0 * * * * /full/path/to/cgi-bin/update.cgi
I upload it to my server. telnet in and type crontab cronfile.txt. I type in crontab -l
and it shows that the cronfile.txt line has been copied in for cron. only its added "odin" to the end,like this:
0 * * * * /full/path/to/cgi-bin/update.cgiodin
the server that I am on is odin.he.net (hurricane electric) But,the hours pass by and no update. Ive contacted the server administrator...but no response today...its Sunday :-(
Im sure I have cron access (obviously...it copies in fine) and I am sure I have the correct path
So...do I have this correct? I have a regular .cgi file like any other right...named update.cgi. Its located in my cgi-bin.
I upload the cronfile.txt which contains:
0 * * * * /full/path/to/cgi-bin/update.cgiodin
(except the odin is added on after I type crontab cronfile.txt and then type crontab -l to verify that it copied)
Am I doing this correctly? Is there something I have missed???? Or is this correct and just something I need to deal with servadmin about???
This being the first time Ive used cron,I dont know if I am doing this correctly (since it doesnt seem to be working) or if I have missed something here or what!
Frusterating......new server...program all written...reconfigured for new server....all working nicely....but no crontab!

...xcom



Jasmine
Administrator / Moderator

Jun 4, 2001, 6:52 AM

Post #7 of 13 (3978 views)
Re: Errrr......... [In reply to] Can't Post

Errr.... are you sure this is exactly what's in your cron list?

0 * * * * /full/path/to/cgi-bin/update.cgiodin

If so, I've never seen a server whose path is /full/path/to Smile Double check your path by typing pwd in the directory where update.cgi is.

Have you received any error emails? They usually go to the default email address.

Jasmine



xcom
stranger

Jun 4, 2001, 10:07 AM

Post #8 of 13 (3974 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

LOL!
no!....my file doesnt say full/path/to!

it says:
0 * * * */home/*username/cgi-bin/update.cgi

--except *username is replaced with my actual username.

The error messages I am getting say:
/bin/sh: /home/heathen1/cgi-bin/update.cg: No such file or directory

...xcom



xcom
stranger

Jun 4, 2001, 11:25 AM

Post #9 of 13 (3972 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Geez! I dont get it!
Ive tried:
0 * * * * /home/*username/cgi-bin/update.cgi
0 * * * * /*username/cgi-bin/update.cgi
0 * * * * /cgi-bin/update.cgi
as well as all of the above without the first /
and everyone is sending me the same message:
/bin/sh: /home/*username/cgi-bin/update.cgi: No such file or directory
/bin/sh: /*username/cgi-bin/update.cgi: No such file or directory
/bin/sh: /cgi-bin/update.cgi: No such file or directory

Yes....I know the file exists! In my cgi-bin and named update.cgi!
Obviously this has something to do with supplying the incorrect path,but geez! I dont know what to do! Ive tried all different ways of supplying the path!
Obviously Im doing something wrong...but I just dont know what it is!
....xcom



xcom
stranger

Jun 4, 2001, 2:06 PM

Post #10 of 13 (3969 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Yes! Finally! Success!
I searched and searched the web for every crontab tutorial I could find. They all pretty much said the same thing. I kept doing what they all said to do,but I kept getting the same error message over and over.
Finally I found a tutorial that specified....... after opening your text editor.........."Firstly switch OFF word wrap if it has this feature."
I turned off wordwrap on notepad....uploaded the new cronfile,and crontabbed it....Voila! That one little tidbit of info that none of the other tutorials mentioned....made all the difference in the world!

....xcom



Pro_4
User

Jun 4, 2001, 4:37 PM

Post #11 of 13 (3966 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Hey,

Xcom can you send me your file or atleast the crontab stuff cause i am trying to figure out how to do that stuff.

Email it to etow_pro_4@hotmail.com .

Thanks i would really appreciate it.

Yes i am a palm tree. What are you plantist or something!?


xcom
stranger

Jun 4, 2001, 9:42 PM

Post #12 of 13 (3963 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Pro_4. Not sure why you want me to email????
But heres what I did.......
Opened notepad. Turned OFF wordwrap. typed in
0 * * * * /home/heathen1/cgi-bin/upate.cgi
That tutorial explained about it being important to hit return (enter) so as to have a blank line after the date/command line,which I did. Also it seemed to make a difference if I uploaded binary or ASCII.
ASCII worked and binary did not. I dont now if that was just a particular characteristic of this server,or if it is necessary and just nobody mentioned it. LOL.
but doing EXACTLY below...it worked:
1)opened text editor (notepad) and turned OFF wordwrap by clicking on the edit tab and deselecting wordwrap.
2)typed in my date/command line:
0 * * * * /home/*username/cgi-bin/update.cgi
So that update.cgi would be executed every hour on the hour.
3)Hit return to create a blank line after the date/command line
4)uploaded the file (named cronfile.txt) to my server in ASCII mode via FTP
5)telnetted into the server with my username/pass and typed crontab cronfile.txt
6)typed crontab -l to see the results...and verify that crontab successfully copied my cronfile.txt

Hope this helps!
...xcom



Pro_4
User

Jun 5, 2001, 9:22 AM

Post #13 of 13 (3959 views)
Re: Almost Finished! Need Help! [In reply to] Can't Post

Thanks thats I needed to know.

:)

Yes i am a palm tree. What are you plantist or something!?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives