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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i create a cron job 2

Status
Not open for further replies.

JCrou82

Programmer
Aug 23, 2002
265
US
I have PHP file that I have created. I saved it in my htdocs directory. I want this file to be ran the first of every month at 2am. The file creates a number of directories and sub directories. I'm an Advanced Begginer in Linux and am not sure how I go about creating a cron job. I've been told that is how i run a script on schedule. what files do i need to edit and how do I tell this "cron job" to run my script in htdocs on the particular date and time every month? Is there any clear tutorials on this. Most of them are pretty confusing to me.

Thanks in advance
 
Headmaster, I agree with you about webmin. So easy.

And some kind soul gave me a coupla stars. Thx.

 
Headmaster: can you post a link to this "webmin" tool so that I can download it and install it on my server. Thanks

I added the shebang line and still no dice. I changed the crontab line to something like this:

40 16 8 5 * php /usr/local/apache/htdocs/042003/global-files/directoryCreator.php

and i get an email with this:
/bin/sh: php: command not found

Also according to this page:

that's the way i am supposed to do it. I tried the stand-alone php way because i was told that if i can run php from a telnet session, then i have php as a standalone. But if i look at phpinfo() it shows me that it's an apache module. how can i be sure?

i'm thinking of scrapping the PHP and doing it in another language. What would you guys suggest? the php script is real simple and i could probly recode it for another language.

Thanks guys!!!
 
Remember, cron does not use your environment. Put the full path to PHP instead of just [tt]php[/tt].
PHP is usually installs both the CGI/CLI binary and the Apache module, so if you run the [tt]phpinfo();[/tt] through Apache, it should display itself as a module.

//Daniel
 
Why have you not used the FAQ as I suggested?

Adding lynx is a not a difficult task; lynx is a text only web browser (very useful for debugging if nothing else), You have already said that you can run your php script from a web browser, so there you have it!

Do you know how to add an .rpm package if so you can add lynx in a few seconds and be up and running.

Ok I'll spell it out just incase:

rpm -Uvh ftp://rpmfind.net/linux/contrib/libc6/i386/lynx-2.8.3-42.i386.rpm

Also you said that your command returned: "/bin/sh: /user/bin/lynx: No such file or directory"

Correct!! unless you have something special its /usr/bin/lynx
If you all ready have it installed want to know how to find out?
as root do: locate lynx <cr>

Now come on stop looking at the horizon or you will trip over yout toes!

L.


 
danielhozac: maybe i'll try what you mentioned, puttin the full path to php instead of just php. we'll see if that works. also what you state about php being installed as both sounds possible to me. that's probably what it is.

tarn: I did attempt your suggestion and i received that error. Of course my eyes overlooked the misspelling of usr instead of user. I will retry your suggestion and see what happens. I also did a locate lynx and returned a number of results, mostly listing in /usr/share/doc/lynx2-8-4/. Does that mean it's installed or should I still download the rpm?

Thanks
 
The results in /usr/share/doc will only be documentation, your looking for /usr/bin/lynx (thats where mine is).

You should probably look for the latest .rpm as that one I pasted is probably not so new but would get you started.

If you find the latest then rpm -Uvh will U{pdate}v{erbose}h{ashes}while updating so even if you already have it you will get an update (if its already there and you try to Update with an OLDER version rpm will tell you and kick out).

Try Sorceforge for latest lynx and webmin (careful webmin can be a handfull to configure, nice tool once it's there and running, but its not a 5min job (more like 5hrs))

Good Luck.
 
Crontab entries :

Webmin Version :
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 8-18 * * 1-5 fetchmail --silent

Handmade Version :
0-57/3 8-18 * * 1-5 fetchmail --silent

Which do you like better ?

 
Nice one bluegroper, I've never thought of using sixty (ok 58 zero to fifty seven) devided by three in that manner in a crontab to get something to run every three minutes. I must try that sometime (if ever I need it :¬) )

L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top