LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-12-2003, 09:24 AM   #1
Gargomel7
LQ Newbie
 
Registered: Sep 2003
Location: Rochester, NY
Distribution: Fedora Core 4
Posts: 12

Rep: Reputation: 0
Daily Cron jobs with a PHP file


I have a php file that scans a MySQL DB for expired articles and will change the necessary entries. The file works great when run manually. I'm just wondering how to run this file in an automatic daily cron?

I saw one post showing a lynx dump, but I have no clue how to even start with setting one up. I'm fairly new to linux, but not to computers. If anyone could help that'd be great.

Thank you.
 
Old 09-12-2003, 09:28 AM   #2
Andy@DP
Member
 
Registered: Aug 2003
Location: Aberdeen, UK.
Distribution: Debian, Ubuntu
Posts: 208
Blog Entries: 2

Rep: Reputation: 30
cron tab would look like this:
0 0 * * * /usr/bin/lynx --dump http://your_php_script> /dev/null

that would run the script daily at midnight.
Take a look at http://www.sitepoint.com/article/1196 for more about php and cron.

Hope this helps
 
Old 09-12-2003, 09:33 AM   #3
Gargomel7
LQ Newbie
 
Registered: Sep 2003
Location: Rochester, NY
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
do i need the > after the link?
 
Old 09-12-2003, 09:34 AM   #4
Gargomel7
LQ Newbie
 
Registered: Sep 2003
Location: Rochester, NY
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
i've read some stuff about setting the file as executable....do i need to do that as well?
 
Old 09-12-2003, 09:40 AM   #5
Andy@DP
Member
 
Registered: Aug 2003
Location: Aberdeen, UK.
Distribution: Debian, Ubuntu
Posts: 208
Blog Entries: 2

Rep: Reputation: 30
yes using chmod to set it world executable i think. The > redirects the output to the DEV/NULL. Dunno what that does but I was told to do it that way by someone when installing some file that ran every 10 minutes
 
Old 09-12-2003, 09:45 AM   #6
Gargomel7
LQ Newbie
 
Registered: Sep 2003
Location: Rochester, NY
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
so chmod 700 and then add the > to the end of the url?
i put this in the cron.daily folder....should i add it to crontab? or is it fine by itself in the cron.daily folder?
 
Old 09-13-2003, 02:52 PM   #7
Gargomel7
LQ Newbie
 
Registered: Sep 2003
Location: Rochester, NY
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
I'm trying to run two separate cron jobs.

The first one runs a php script that is supposed to update a mysql database. The script works fine when its run manually, but i wanted it to run as a cron.
i set the file to executable chmod 700, here's the line i put in the file.
0 0 * * * /usr/bin/lynx --dump http://ip/knowledge_base/athena/cust..._pnp_check.php> /dev/null/

i checked my root mail for today and got this message:
/etc/cron.daily/expired_pnp:
/etc/cron.daily/expired_pnp: line 1: /dev/null/ is a directory

my other cron job i'm trying to set up is a mysql dump.
again i set hte file to executable and here is what is in the file:
#!/bin/bash

mysqldump -uusername -ppassword --databases knowledge_db -c -e > /mnt/backups/`date +%m%d%y`.knowledge_db.sql
mysqldump -uusername -ppassword --databases knowledge_db -c -e | sendmail email@email.com
it couldn't send th email for some reason regarding the sendmail setup, but i got an error in my mail showing:
/etc/cron.daily/knowledge_db_dump:
/etc/cron.dialy/knowledge_db_dump: line 3: /mnt/backups/091303.knowledge_db.sql: No such file or directory.

Any help would be greatly appreciated. I'm kinda pulling out my hair at this point.

Thanks in advance.

Last edited by Gargomel7; 09-13-2003 at 06:27 PM.
 
Old 09-13-2003, 07:21 PM   #8
Gargomel7
LQ Newbie
 
Registered: Sep 2003
Location: Rochester, NY
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
thanks to the jerk that logged in and changed the pw. =o)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
logging daily cron jobs in separate files csmwlee Linux - Newbie 5 10-10-2005 10:30 AM
cron.daily question ralvy Slackware 6 12-09-2004 10:55 PM
cron.daily MrJoshua Linux - General 2 03-19-2003 12:09 PM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM


All times are GMT -5. The time now is 05:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration