LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-17-2008, 06:56 AM   #1
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185

Rep: Reputation: 17
Interesting cron happenings


I have an ftp server so fellow members of my design group can share large files.. Anyway I like to keep tabs on everything so I created a cron job to send me some logs every morning. My crontab file looks like this:


[root@bighat ftptools]# crontab -l
10 * * * * /root/ftptools/set_ogp.sh
* 6 * * * /root/ftptools/send_logs.sh
[root@bighat ftptools]#


The first cron job sets permissions on my ftp files so everyone will have access to everyone elses files, works great.

Second crontab is called send_logs.sh and that basically sends me an email using sendmail and places the last 400 lines of each log into the emails. Here is what that file looks like:

[root@bighat ftptools]# cat send_logs.sh
tail -400 /var/log/xferlog | /usr/sbin/sendmail -f xferlog savone@aivila.net
tail -400 /var/log/secure | /usr/sbin/sendmail -f xferlog savone@aivila.net


So when I run that file manually I get 2 nice emails with what I would expect to get in them. When it runs via cron I get 120+ emails, basically 60 duplicates of each email.

Since its set to run at 6am I figured I would show you the cron log:


Jan 17 05:01:01 bighat CROND[25632]: (root) CMD (run-parts /etc/cron.hourly)
Jan 17 05:10:01 bighat CROND[25635]: (root) CMD (/root/ftptools/set_ogp.sh)
Jan 17 06:00:01 bighat CROND[25773]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:01:01 bighat CROND[25788]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:01:01 bighat CROND[25789]: (root) CMD (run-parts /etc/cron.hourly)
Jan 17 06:02:01 bighat CROND[25802]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:03:01 bighat CROND[25815]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:04:01 bighat CROND[25828]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:05:01 bighat CROND[25841]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:06:01 bighat CROND[25854]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:07:01 bighat CROND[25867]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:08:01 bighat CROND[25880]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:09:01 bighat CROND[25893]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:10:01 bighat CROND[25908]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:10:01 bighat CROND[25909]: (root) CMD (/root/ftptools/set_ogp.sh)
Jan 17 06:11:01 bighat CROND[25930]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:12:01 bighat CROND[25943]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:13:01 bighat CROND[25956]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:14:01 bighat CROND[25969]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:15:01 bighat CROND[25982]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:16:01 bighat CROND[25995]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:17:01 bighat CROND[26008]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:18:01 bighat CROND[26021]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:19:01 bighat CROND[26034]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:20:01 bighat CROND[26047]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:21:01 bighat CROND[26060]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:22:01 bighat CROND[26073]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:23:01 bighat CROND[26103]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:24:01 bighat CROND[26116]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:25:01 bighat CROND[26129]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:26:01 bighat CROND[26142]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:27:01 bighat CROND[26173]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:28:01 bighat CROND[26295]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:29:01 bighat CROND[26308]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:30:01 bighat CROND[26321]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:31:01 bighat CROND[26334]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:32:01 bighat CROND[26347]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:33:01 bighat CROND[26360]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:34:01 bighat CROND[26373]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:35:01 bighat CROND[26386]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:36:01 bighat CROND[26399]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:37:01 bighat CROND[26412]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:38:01 bighat CROND[26425]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:39:01 bighat CROND[26438]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:40:01 bighat CROND[26451]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:41:02 bighat CROND[26464]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:42:01 bighat CROND[26477]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:43:01 bighat CROND[26490]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:44:01 bighat CROND[26503]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:45:01 bighat CROND[26516]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:46:01 bighat CROND[26529]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:47:01 bighat CROND[26542]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:48:01 bighat CROND[26555]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:49:01 bighat CROND[26568]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:50:01 bighat CROND[26581]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:51:01 bighat CROND[26594]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:52:01 bighat CROND[26607]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:53:01 bighat CROND[26620]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:54:01 bighat CROND[26633]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:55:01 bighat CROND[26646]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:56:01 bighat CROND[26659]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:57:01 bighat CROND[26672]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:58:01 bighat CROND[26685]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 06:59:01 bighat CROND[26698]: (root) CMD (/root/ftptools/send_logs.sh)
Jan 17 07:01:01 bighat CROND[26711]: (root) CMD (run-parts /etc/cron.hourly)
Jan 17 07:10:01 bighat CROND[26714]: (root) CMD (/root/ftptools/set_ogp.sh)
Jan 17 07:28:09 bighat crontab[26911]: (root) LIST (root)
Jan 17 07:47:29 bighat crontab[26917]: (root) LIST (root)





Does anyone have any ideas why it would repeat itself 60 times?
 
Old 01-17-2008, 07:05 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Because it runs every minute from 6:00 to 6:59. The crontab entry should be:
Code:
0 6 * * * /root/ftptools/send_logs.sh
 
Old 01-17-2008, 07:25 AM   #3
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by colucix View Post
Because it runs every minute from 6:00 to 6:59. The crontab entry should be:
Code:
0 6 * * * /root/ftptools/send_logs.sh
Thats why I love this place, thanks a million that would explain it perfectly!
 
Old 01-17-2008, 07:47 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
He he... you're welcome!
 
  


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
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
LXer: Linux happenings in '06 LXer Syndicated Linux News 0 01-06-2006 01:46 AM
weird C happenings ...... purpleburple Programming 4 08-19-2002 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:01 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration