LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 07-29-2004, 08:31 AM   #1
init
Member
 
Registered: Oct 2003
Location: Portland, Maine
Distribution: Gentoo 2004_2 2.6.7r14
Posts: 160

Rep: Reputation: 30
Cron job to run every monday wednesday and friday...?


I have searched around for a bit with no luck. I want to run a job every monday wednesday and fri at 12:00am from the cron. I am running vixe-cron.

Code:
crontab -l
Code:
 0 0 * * 1,3,5 /etc/backup/backupscp.sh
I thought this was the correct way but I guess not.

Everwhere I search I pull up all kinds of examples but none that tell me what I am looking for.
I want to avoid using the day of the month field because it will be different every month.

Thanks

Last edited by init; 07-29-2004 at 08:33 AM.
 
Old 07-29-2004, 10:27 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Is the script itself failing?

Hi -

Your "cron" syntax looks OK - maybe the problem lies elsewhere?

Your "cron" user environment is *different* from your logon environment: there are some subtle differences in which environment variables are defined, how they're defined, and your file permissions.

Please try this:

1. Write a "dummy", ("hello world") script and verify that you can execute it through "cron"
2. Add logging to your "real" script and verify that it's doing what you think it should be doing.

My guess is that your "backup" is probably successfully being invoked by "cron" ... and then silently failing.

'Hope that helps .. PSM
 
Old 07-29-2004, 11:04 AM   #3
init
Member
 
Registered: Oct 2003
Location: Portland, Maine
Distribution: Gentoo 2004_2 2.6.7r14
Posts: 160

Original Poster
Rep: Reputation: 30
I have other cron jobs running properly. this is my root user crontab

Code:
 0 1 * * * /usr/bin/emerge sync
                                                                                
0 2 * * * /usr/sbin/fixpackages > /dev/null 2>&1
                                                                                
0 3 * * * /usr/bin/updatedb
                                                                                
1 * * * * /usr/bin/ntpdate -b molecule.ecn.purdue.edu > /dev/null 2>&1
0 2 * * 1,3,5 /etc/backup/backup.sh
most of these will email me via 2>&1

snipit
Code:
#Snip-Snap Backups
rm -rf /root/backups/mysql/snip-xml-*
rm -rf /root/backups/web-root/snip-htdocs-*
cd /var/www/localhost/htdocs
tar -zcPpf /root/backups/web-root/snip-htdocs-`date +%m%d%y`-tar.gz _snipsnap > snip-backup.log 2>&1 > snip-backup.log
[ -s snip-backup.log ] && cat snip-backup.log | mail -s 'snip-backup.log' root
rm snip-backup.log
$MYDUMPX snipsnap > /root/backups/mysql/snip-xml-`date +%m%d%y`.sql
The only thing I dont like is that I only have mail notification on certine parts, I would like to log the hole script and have that sent out via e-mail also.

can I add this to the crontab to log
Code:
0 2 * * 1,3,5 /etc/backup/backup.sh > host-backup.log 2>&1 > host-backup.log; cat host-backup.log | mail -s 'host-backup output' root
This is less important than getting it to work in the crontab of course but it would help me see all the output.


also I can run these scripts by manually with no errors.
 
Old 07-29-2004, 11:22 AM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You're definitely on the right track...

Sounds good.

I definitely think the problem is likely with your user permissions and environment running under "cron" (vs running from the command line). Your logging "2>$1 host-backup.log" is definitely the way to go.

Please make sure you have universal write access ("umask 0; chmod +rw host-backup.log ") and please consider adding some additional "echo" statements to your script to make sure that you can actually write to it during your backup.

Good luck - I think you'll have the problem resolved quickly!

Your .. PSM
 
Old 07-29-2004, 11:24 AM   #5
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Whoops - I meant "2>&1 host-backup"...
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to run cron job fahad26 Linux - General 3 06-30-2005 01:51 AM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM
Cron job does not run brentos Linux - General 6 12-12-2003 02:37 PM
how to set cron job to run every 5 mins? gsbarry Linux - General 7 05-28-2003 12:30 PM


All times are GMT -5. The time now is 05:28 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