<?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: Shell script to compare the date !! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717062#M62166</link>
    <description>Thanks for all of your suggestions.  I've already made use of Clay's Caljd.sh to finish my task!!&lt;BR /&gt;&lt;BR /&gt;I created a script which calls Caljd.sh to calculate the julian day for me.  Then I compare the current Julian day and the returned Julian days from the /var/adm/acct/sum/loginlog file (suppose a cron job will run the lastlogin command everyday to update the logiinlog file).&lt;BR /&gt;&lt;BR /&gt;If the current Julian day - returned Julian day &amp;gt;= 90 days (i.e 3 months roughly), the particular username will be printed out in a report.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Chris,</description>
    <pubDate>Sun, 05 May 2002 13:13:04 GMT</pubDate>
    <dc:creator>Chris Fung</dc:creator>
    <dc:date>2002-05-05T13:13:04Z</dc:date>
    <item>
      <title>Shell script to compare the date !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717058#M62162</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I would like to write a script for tracking those users who were not logged in to the server for more than 3 months.  By comparing the /bin/last output for /var/adm/wtmp file and password file, I obtained a list of username and timestamps for their login and logout time.  Now the problem is how can I compare the date specified in /var/adm/wtmp file with the current date??  I couldn't find any useful command for this task.&lt;BR /&gt;&lt;BR /&gt;Appreciated it if anyone can help solving this problem with sample codes and/or url links.&lt;BR /&gt;&lt;BR /&gt;Many thanks,&lt;BR /&gt;&lt;BR /&gt;Chris,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 04 May 2002 07:25:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717058#M62162</guid>
      <dc:creator>Chris Fung</dc:creator>
      <dc:date>2002-05-04T07:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to compare the date !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717059#M62163</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Try putting A. Clay Stephenson's caljd.sh script to good use, where possible:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6e7a7d4cf554d611abdb0090277a778c,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6e7a7d4cf554d611abdb0090277a778c,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Sat, 04 May 2002 08:09:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717059#M62163</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-05-04T08:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to compare the date !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717060#M62164</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This is one of those cases where caljd.sh (or the newer caljd.pl) is probably not the best choice. My approach would be to use that really big number (the epoch seconds timestamp) just before the month.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;FIN=/var/adm/wtmp&lt;BR /&gt;CMD=/usr/sbin/acct/fwtmp&lt;BR /&gt;&lt;BR /&gt;STAT=1&lt;BR /&gt;if [ -r ${FIN} -a -x ${CMD} ]&lt;BR /&gt;  then&lt;BR /&gt;    ${CMD} &amp;lt; ${FIN} | perl wtmpparse.pl&lt;BR /&gt;    STAT=$?&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;The attached wtmpparse.pl script will then look at the timestamp and append something like '32.45 days' to each input line. If you look at the perl script, you will see a commented line that will instead output an integer '32 days' instead. &lt;BR /&gt;&lt;BR /&gt;This should be very close to your needs. You may also need to play with the substr() offset to locate the timestamp within your platform's fwtmp output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 04 May 2002 14:03:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717060#M62164</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-05-04T14:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to compare the date !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717061#M62165</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;One another way I can think of is to check the home directory using -mtime option of find.&lt;BR /&gt;&lt;BR /&gt;1. Get the user list from /etc/passwd&lt;BR /&gt;2. For each user, determine if any of the files in his/her home directory have been modified since the desired number of days. .last_login is one such file by default gets modified when the user logs in.&lt;BR /&gt;&lt;BR /&gt;A primitive script is below. You can modify it to your requirements.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;if [ $# != 1 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Usage: $0 days_of_inactivity"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;STAMP=$1&lt;BR /&gt;&lt;BR /&gt;cat /etc/passwd |&lt;BR /&gt;while read entry&lt;BR /&gt;do&lt;BR /&gt;   LOGIN=`echo $entry |awk  '{FS=":";print $1}'`&lt;BR /&gt;   HOME=`echo $entry |awk  '{FS=":";print $6}'`&lt;BR /&gt;&lt;BR /&gt;      SUCCESS=`find $HOME -mtime -$STAMP -print -quit | wc -l`&lt;BR /&gt;&lt;BR /&gt;      if [ $SUCCESS -eq 0 ]&lt;BR /&gt;      then&lt;BR /&gt;         echo "$LOGIN "&lt;BR /&gt;      fi&lt;BR /&gt;done</description>
      <pubDate>Sun, 05 May 2002 02:40:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717061#M62165</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-05-05T02:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to compare the date !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717062#M62166</link>
      <description>Thanks for all of your suggestions.  I've already made use of Clay's Caljd.sh to finish my task!!&lt;BR /&gt;&lt;BR /&gt;I created a script which calls Caljd.sh to calculate the julian day for me.  Then I compare the current Julian day and the returned Julian days from the /var/adm/acct/sum/loginlog file (suppose a cron job will run the lastlogin command everyday to update the logiinlog file).&lt;BR /&gt;&lt;BR /&gt;If the current Julian day - returned Julian day &amp;gt;= 90 days (i.e 3 months roughly), the particular username will be printed out in a report.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Chris,</description>
      <pubDate>Sun, 05 May 2002 13:13:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-compare-the-date/m-p/2717062#M62166</guid>
      <dc:creator>Chris Fung</dc:creator>
      <dc:date>2002-05-05T13:13:04Z</dc:date>
    </item>
  </channel>
</rss>

