User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,515 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,718 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1787 | Replies: 3
Reply
Join Date: Sep 2007
Posts: 2
Reputation: Marlow is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Marlow Marlow is offline Offline
Newbie Poster

Question php script cron jobs

  #1  
Sep 25th, 2007
i use php for web dev and i need to create cron jobs in cpanel but it seems i need to have a knowledge of linux/unix. is there a way out? or a friendly solution? help, anyone. Thenks.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 487
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 73
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: php script cron jobs

  #2  
Sep 25th, 2007
Well if you have linux then it never hurts to learn the linux commands (cron) whereas if you have Windows you will be using AT instead of cron. In either case getting to know your way around the command line is a good thing.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h-->++ r z+*
Reply With Quote  
Join Date: Sep 2007
Posts: 14
Reputation: kaykays is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
kaykays kaykays is offline Offline
Newbie Poster

Re: php script cron jobs

  #3  
Sep 26th, 2007
As ShawnCplus said, it is useful to know the basic commands.

If you want to run a php script as cron, use this command to set it up in your cpanel cron:

wget -q --delete-after script-name

where script-name is the full url of the script (complete with http)
PHP | ASP
Reply With Quote  
Join Date: Sep 2007
Location: Nevada, U.S.A.
Posts: 54
Reputation: HazardTW is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
HazardTW HazardTW is offline Offline
Junior Poster in Training

Re: php script cron jobs

  #4  
Feb 1st, 2008
wget is awesome!

I had been wanting to find a way to do database dumps daily of my client's websites and store them in .sql files on my server at home.

I have a password protected script on each website that when accessed with the proper code, it's output is a dump of the database in .sql format.

On my server at home I wrote a script that uses file_get_contents() to access the script on each website, if it gets a return, it names it according to db name, date, and time, and saves the sql file, then it checks all saved .sql files for their age, if they are older than 7 days it deletes them.

The script on my local server does not output anything, if the retrieval of the database dump fails, it writes a failure notice to the .sql file and flags the filename so I know it's a bad one.

I set up cron job to use wget to run my local script every night at midnight, and I end up with a backup of all my client's db's every day for the last 7 days.

I suppose I could use wget to get the sql dumps directly, but for me it was just easier to write a local script that would take care of naming and old file deletion.

Also threw a page in my local server to list any .sql files that exist for download or delete them, and the option to run a database dump on the spot.

I sure beats paying for backup service or manually doing backups, plus I have seen hosts have such severe hardware problems that they lost the contents of an entire server AND all backups newer than 9 days old.
Last edited by HazardTW : Feb 1st, 2008 at 4:17 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC