<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get lines out of /var/mail/root in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861139#M98360</link>
    <description>Sally,&lt;BR /&gt;&lt;BR /&gt;A single cron job is logged to /var/adm/cron/log in this format:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; CMD: &lt;COMMAND&gt;&lt;BR /&gt;&amp;gt; &lt;USER&gt; &lt;PID&gt; &lt;DATE&gt;&lt;BR /&gt;&amp;lt; &lt;USER&gt; &lt;PID&gt; &lt;DATE&gt;&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  CMD:  /home/root/filecleanup.sh &amp;gt; /dev/null  &lt;BR /&gt;&amp;gt;  root 2328 c Sat Jul 29 19:10:00 EDT 2006&lt;BR /&gt;... Other entries ...&lt;BR /&gt;&amp;lt;  root 2328 c Sat Jul 29 19:12:57 EDT 2006&lt;BR /&gt;&lt;BR /&gt;To find the end time for any job, just match the pid to the start time.&lt;BR /&gt;&lt;BR /&gt;PCS&lt;BR /&gt;&lt;/DATE&gt;&lt;/PID&gt;&lt;/USER&gt;&lt;/DATE&gt;&lt;/PID&gt;&lt;/USER&gt;&lt;/COMMAND&gt;</description>
    <pubDate>Tue, 12 Sep 2006 09:27:50 GMT</pubDate>
    <dc:creator>spex</dc:creator>
    <dc:date>2006-09-12T09:27:50Z</dc:date>
    <item>
      <title>Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861129#M98350</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a whole bunch of emails come in each morning.  I need to get the first and last line (date stamp and what cron job ran) out of each message.  The problem is that /var/mail/root turns out to be one big file rather than all seperate messages, how you see them with "elm".  Is there a way to do this?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 12 Sep 2006 07:09:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861129#M98350</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-09-12T07:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861130#M98351</link>
      <description>Shalom Sally,&lt;BR /&gt;&lt;BR /&gt;You merely type elm at the command prompt of an HP-9000 system. Assuming root mail is not diverted elsewhere by /etc/aliases this will let you view what you need.&lt;BR /&gt;&lt;BR /&gt;You can also install qpopper from the Internet Express kit and read the mail into your outlook mail reader if you are unfortunate enough to use windows.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 12 Sep 2006 07:18:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861130#M98351</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-09-12T07:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861131#M98352</link>
      <description>Sally,&lt;BR /&gt;can't you use /var/adm/cron/log ?</description>
      <pubDate>Tue, 12 Sep 2006 07:18:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861131#M98352</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-09-12T07:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861132#M98353</link>
      <description>Sally,&lt;BR /&gt;&lt;BR /&gt;See /var/adm/cron/log.&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Tue, 12 Sep 2006 07:21:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861132#M98353</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-09-12T07:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861133#M98354</link>
      <description>Why not have root mail forwarded to your email?&lt;BR /&gt;&lt;BR /&gt;In /etc/mail/aliases&lt;BR /&gt;&lt;BR /&gt;root: sdevine&lt;BR /&gt;sdevine: sdevine@yourdomain.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then run: newaliases&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Tue, 12 Sep 2006 07:22:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861133#M98354</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-09-12T07:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861134#M98355</link>
      <description>You're going to need to use sed to print the line before and the line after the "From" line:&lt;BR /&gt;&lt;BR /&gt;# print 1 line of context before and after regexp, with line number&lt;BR /&gt; # indicating where the regexp occurred (similar to "grep -A1 -B1")&lt;BR /&gt; sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h&lt;BR /&gt;&lt;BR /&gt;From "Handy One-Liners For Sed" (attached).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 12 Sep 2006 07:23:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861134#M98355</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-09-12T07:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861135#M98356</link>
      <description>The cron log shows some of them but not all of them.  There are many lines that show the date/time stamp but not the script that ran.</description>
      <pubDate>Tue, 12 Sep 2006 08:57:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861135#M98356</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-09-12T08:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861136#M98357</link>
      <description>Actually, as long as the last line is somewhat consistent, you could probably just use grep.  For example, all our jobs run from the /apps directory, so the last line is going to contain "apps".  In this case all you would need to do is run something like this:&lt;BR /&gt;&lt;BR /&gt;grep -e From -e apps /var/mail/informix |grep -v "From:"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 12 Sep 2006 09:16:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861136#M98357</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-09-12T09:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861137#M98358</link>
      <description>Plus the cron/log looks like the timestamp is when it starts...I need the finish time.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Sep 2006 09:22:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861137#M98358</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-09-12T09:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861138#M98359</link>
      <description>By grepping from /var/mail file, you get the time when the email was sent which should be the finish time.  The only trick is catching the last line of the email:  easy if you run every thing from one directory and only slightly more complicated if there are multiple directories.  Here's my sample output:&lt;BR /&gt;&lt;BR /&gt;grep -e From -e apps /var/mail/informix |grep -v "From:"&lt;BR /&gt;From root Tue Sep 12 09:28:19 EDT 2006&lt;BR /&gt;/apps/hols/bin/hh/cleanUp.ksh&lt;BR /&gt;&lt;BR /&gt;If there are multiple source directories, you can simply add them with multiple "-e" entries.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 12 Sep 2006 09:26:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861138#M98359</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-09-12T09:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861139#M98360</link>
      <description>Sally,&lt;BR /&gt;&lt;BR /&gt;A single cron job is logged to /var/adm/cron/log in this format:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; CMD: &lt;COMMAND&gt;&lt;BR /&gt;&amp;gt; &lt;USER&gt; &lt;PID&gt; &lt;DATE&gt;&lt;BR /&gt;&amp;lt; &lt;USER&gt; &lt;PID&gt; &lt;DATE&gt;&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  CMD:  /home/root/filecleanup.sh &amp;gt; /dev/null  &lt;BR /&gt;&amp;gt;  root 2328 c Sat Jul 29 19:10:00 EDT 2006&lt;BR /&gt;... Other entries ...&lt;BR /&gt;&amp;lt;  root 2328 c Sat Jul 29 19:12:57 EDT 2006&lt;BR /&gt;&lt;BR /&gt;To find the end time for any job, just match the pid to the start time.&lt;BR /&gt;&lt;BR /&gt;PCS&lt;BR /&gt;&lt;/DATE&gt;&lt;/PID&gt;&lt;/USER&gt;&lt;/DATE&gt;&lt;/PID&gt;&lt;/USER&gt;&lt;/COMMAND&gt;</description>
      <pubDate>Tue, 12 Sep 2006 09:27:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861139#M98360</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-09-12T09:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get lines out of /var/mail/root</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861140#M98361</link>
      <description>&lt;!--!*#--&gt;Hey;&lt;BR /&gt;&lt;BR /&gt;Interesting idea for a script - so I wrote it :)!&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;=cut&lt;BR /&gt;###############################################################&lt;BR /&gt;bad_crons:  Attempts to ID cron jobs that are sending mail to root&lt;BR /&gt;            Created based on an idea from itrc.&lt;BR /&gt;Author:     Doug O'Leary&lt;BR /&gt;Created:    09/12/06&lt;BR /&gt;###############################################################&lt;BR /&gt;=cut&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;my $last = '';&lt;BR /&gt;my $first = '';&lt;BR /&gt;my $subj = '';&lt;BR /&gt;&lt;BR /&gt;my $mail_file = "/var/mail/root";&lt;BR /&gt;open (In, "&amp;lt; $mail_file") || die "Can't read $mail_file - ($!)";&lt;BR /&gt;while (&lt;IN&gt;)&lt;BR /&gt;{  next if (/^\s*$/);&lt;BR /&gt;   chomp;&lt;BR /&gt;   switch:&lt;BR /&gt;   {  if  (/^From root/)&lt;BR /&gt;      {  printf("%-30s %s\n", $first, $last)&lt;BR /&gt;            if (length($first) &amp;gt; 0 &amp;amp;&amp;amp; length($subj) &amp;gt; 0);&lt;BR /&gt;         ($first) = $_ =~ m{from root[^\s]* (.*)}i;&lt;BR /&gt;         $subj = '';&lt;BR /&gt;         last switch;&lt;BR /&gt;      }&lt;BR /&gt;      if (/^Subject:\s+cron$/)&lt;BR /&gt;      {  $subj = 'cron'; last switch;  }&lt;BR /&gt;      $last = $_;&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;close In;&lt;BR /&gt;&lt;BR /&gt;sample output using one of my problem systems:&lt;BR /&gt;Mon Sep 11 08:02:01 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 09:02:01 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 10:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 11:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 12:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 13:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 14:02:01 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 14:02:01 EDT 2006   /usr/contrib/bin/secfile.sh&lt;BR /&gt;Mon Sep 11 14:02:01 EDT 2006   /usr/contrib/bin/secfile.sh&lt;BR /&gt;Mon Sep 11 16:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Mon Sep 11 18:02:01 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Tue Sep 12 01:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Tue Sep 12 02:20:10 EDT 2006   /usr/local/bin/scanlog&lt;BR /&gt;Tue Sep 12 03:35:02 EDT 2006   /usr/local/bin/cleanall -r&lt;BR /&gt;Tue Sep 12 04:02:01 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Tue Sep 12 05:02:01 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;Tue Sep 12 07:02:00 EDT 2006   /usr/contrib/bin/check_root&lt;BR /&gt;&lt;BR /&gt;HTH;&lt;BR /&gt;&lt;BR /&gt;Doug&lt;BR /&gt;&lt;BR /&gt;&lt;/IN&gt;</description>
      <pubDate>Tue, 12 Sep 2006 09:44:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-lines-out-of-var-mail-root/m-p/3861140#M98361</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-09-12T09:44:37Z</dc:date>
    </item>
  </channel>
</rss>

