Tag Archives: DATE

Finding difference in 2 different timestamps

By sdosanjh

Legends,

I have a requirement to run the script exactly after one hour of completion of dependent script.

Code:

Eg: Script B should run after one hour on the completion of Script A.


I got the time stamps using following variables. these scripts runs in autosys

Code:

> DATE=`date +%H:%M`
> JOB=`jobhist act abcjob |tail -1 | awk '{print $6}'`

> echo $JOB $DATE
03:23 09:54

> DIFF=`expr $DATE - $JOB`
expr: non-numeric argument


how to get the timestamp difference.
if diff is more than one then run the job, else, wait for one hour.
how to calculate that . please help

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Inserting text into a file with awk or sed

By Schubi

Hello,

I’ve been trying to get a script working that fetches weather-data and converts it into an .ics file. The script works so far put I’m stuck at the point where I need to add specific static data. A thorough search through the forum did not point me into the right direction.

Code:

#!/bin/bash
##### Begin
DATE=$(date +'%Y%d%m')
TIME=$(date +'%H:%M:%S')
TEMPFILE="$(mktemp temp.XXX)"

if [ $? -ne 0 ]; then
echo "$0: Can't create temp file, exiting..."
exit 1
fi

##### Fetching weather data
curl http://ical.wunderground.com/auto/ical/global/stations/48698.ics?units=metric | awk 'NR==1 || NR==5 || NR==6 || NR==10 || NR==17 || NR==18 || NR==22 || NR==24 || NR==135' > $TEMPFILE

##### Adding specific calendar data

##### Cleaning up
cat $TEMPFILE | tr -d "r" > $DATE.ics
rm $TEMPFILE
exit 0


The output is as expected a .ics file that can be imported into a calendar:

Code:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20130412T000000Z
DTSTART;VALUE=DATE:20130412
SUMMARY:Thunderstorm 32C / 26C
END:VEVENT
END:VCALENDAR


In addition to the above output, the following data set needs to be imported between lines 3 and 4:

Code:

BEGIN:VTIMEZONE
TZID:Asia/Singapore
BEGIN:DAYLIGHT
TZOFFSETFROM:+0700
DTSTART:19330101T000000
TZNAME:GMT+08:00
TZOFFSETTO:+0720
RDATE:19330101T000000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0730
DTSTART:19820101T000000
TZNAME:GMT+08:00
TZOFFSETTO:+0800
RDATE:19820101T000000
END:STANDARD
END:VTIMEZONE


I’ve been playing around with the following string but did not manage to produce a result (example):
awk ‘NR==4{$0=”BEGIN:VTIMEZONE”}1′ $TEMPFILE

Any help is appreciated!

From: http://www.unix.com/unix-dummies-questions-answers/221013-inserting-text-into-file-awk-sed.html

Cryptography Research to Speak on Anti-Counterfeiting IC Design Techniques at DATE 2013 Conference

By Business Wirevia The Motley Fool

Filed under:

Cryptography Research to Speak on Anti-Counterfeiting IC Design Techniques at DATE 2013 Conference

SAN FRANCISCO–(BUSINESS WIRE)– Cryptography Research, Inc.:

…read more
Source: FULL ARTICLE at DailyFinance

Who:

 

Cryptography Research, Inc.

 

Where:

DATE 2013 Conference
Alpexpo Espace Alpes Congres

Ecolab Schedules Webcast of Industry Conference for March 20

By Business Wirevia The Motley Fool

Filed under:

Ecolab Schedules Webcast of Industry Conference for March 20

ST. PAUL, Minn.–(BUSINESS WIRE)– Daniel J. Schmechel, Ecolab’s Chief Financial Officer, will address financial analysts at the Gabelli & Company’s Specialty Chemicals Conference on Wednesday, March 20, in New York. Ecolab will host a live webcast of Mr. Schmechel’s presentation. Details for the webcast are as follows:

…read more
Source: FULL ARTICLE at DailyFinance

 

TIME:

    12:00 pm Eastern Time
 

DATE:

Ecolab Schedules Webcast of Industry Conference for March 12

By Business Wirevia The Motley Fool

Filed under:

Ecolab Schedules Webcast of Industry Conference for March 12

ST. PAUL, Minn.–(BUSINESS WIRE)– Ecolab Inc.’s Chairman of the Board and Chief Executive Officer, Douglas M. Baker, Jr., will address financial analysts at the Credit Suisse 14th Annual Global Services Conference in Scottsdale, Ariz., on Tuesday, March 12. Ecolab will host a live webcast of Mr. Baker’s presentation. Details for the webcast are as follows:

     

TIME:

2:30 pm Eastern Time
 

DATE:

…read more
Source: FULL ARTICLE at DailyFinance

Mentor Graphics to Sponsor Technical Session and Luncheon at DATE 2013

By Business Wirevia The Motley Fool

Filed under:

Mentor Graphics to Sponsor Technical Session and Luncheon at DATE 2013

WILSONVILLE, Ore.–(BUSINESS WIRE)– Mentor Graphics Corporation (NAS: MENT) today announced their participation with STMicroelectronics and LETI in a technical session and luncheon during the DATE conference in Grenoble, France on March 19, 2013.


Who:
Mentor Graphics, STMicroelectronics and LETI


What:
Technical session to address semiconductor alternative processes for advanced CMOS


When:
Tuesday, 19 March, 2013, 13:00 – 14:00 (Lunch provided to attendees)


Where:
Auditorium Dauphine, ALPEXPO, Grenoble, France

Grenoble ecosystem to provide semiconductor alternative process for advanced CMOS

The session presents the Ultra-Thin Body and Box (UTBB) Fully Depleted SOI (FDSOI) process and shows that it meets requirements for high-performance at low-power and high-energy efficiency. The 28nm FDSOI, 14nm FDSOI, and 10nm FDSOI nodes offer a practical and cost-effective roadmap to shrink features and enable a significant boost for “green” products. With unmatched access resistance and electrostatic characteristics, planar SOI is superior to other technologies based on bulk CMOS technology or FinFET architecture. Product silicon demonstrates outstanding performances for low-power applications in consumer electronics, including tablets and mobile phones. The session will address manufacturing capabilities, design infrastructure and future R&D roadmaps.

Presentations will be given by the following companies and spokespeople:

  • “FDSOI: from successful collaborative R&D to successful Silicon results,” by Philippe Magarshack, executive vice-president, STMicroelectronics
  • “Design infrastructure to support advanced FDSOI below 20nm,” by Jean-Marc Talbot, director of Mentor Graphics …read more
    Source: FULL ARTICLE at DailyFinance

Remove part of a file based on identifiers

By vivek d r

here below is a part of the file

Code:

cat fileName.txt

NAME=APP-VA-va_mediaservices-113009-VA_MS_MEDIA_SERVER_NOT_PRESENT-S
FIXED=false
DATE= 2013-02-19 03:46:04.4
PRIORITY=HIGH
RESOURCE NAME=ccm113

NAME=APP-DS-ds_ha-140020-databaseReplicationFailure-S
FIXED=false
DATE= 2013-02-19 03:46:04.4
PRIORITY=LOW
RESOURCE NAME=ccm113

NAME=APP-MS-service_monitoring-118035-MS_DeviceDeployError-S
FIXED=false
DATE= 2013-02-19 03:46:04.4
PRIORITY=HIGH
RESOURCE NAME=ccm113

NAME=APP-VA-va_trunkgroup_mgr-114000-VA_TGM_TRUNK_FAILURE-S
FIXED=false
DATE= 2013-02-17 07:58:55.3
PRIORITY=HIGH
RESOURCE NAME=ccm114


this file is divided into blocks.. starting from Name and ending with Resource Name…. so if any block whose priority is LOW, i need to remove that block from the file… so what my final output file should have is

Code:

cat fileName.txt

NAME=APP-VA-va_mediaservices-113009-VA_MS_MEDIA_SERVER_NOT_PRESENT-S
FIXED=false
DATE= 2013-02-19 03:46:04.4
PRIORITY=HIGH
RESOURCE NAME=ccm113

NAME=APP-MS-service_monitoring-118035-MS_DeviceDeployError-S
FIXED=false
DATE= 2013-02-19 03:46:04.4
PRIORITY=HIGH
RESOURCE NAME=ccm113

NAME=APP-VA-va_trunkgroup_mgr-114000-VA_TGM_TRUNK_FAILURE-S
FIXED=false
DATE= 2013-02-17 07:58:55.3
PRIORITY=HIGH
RESOURCE NAME=ccm114


any help is appreciated.. thanks

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Multiple command execution inside awk command during xml parsing

By vivek d r

below is the output xml string from some other command and i will be parsing it using awk

Code:

cat /tmp/alerts.xml

.
.
.
etc ect


which i will be parsing using below command

Code:

awk -F'[=|"||,]' '{for(i=1;i<=NF;i++){
if($i=="Alert id") {
if(id!="")
if(dt!=""){ printf "ID=%dnNAME=%snFIXED=%snDATE=%snAlDefID=%dnn", id,nm,fx,dt,alDFid; }
id=($i=="Alert id")?$(i+2):id; }
nm=($i==" name")?$(i+2):nm;
fx=($i==" fixed")?$(i+2):fx;
dt=($i~/^ [0-9]+-/)?$i" "$(i+1):dt;
alDFid=($i==" alertDefinitionId")?$(i+2):alDFid;
}
}END{
if(dt!=""){
printf "ID=%dnNAME=%snFIXED=%snDATE=%snAlDefID=%dnn", id,nm,fx,dt,alDFid;
}
}' /tmp/alerts.xml


output will be as below

Code:

ID=10102
NAME=APP-DS-ds_ha-140018-componentFailure-S
FIXED=false
DATE= 2013-01-29 04:58:27.6
AlDefID=13982
.
.
.etc etc many entries will be there


what i want to achieve is
>in the awk command i want to implement a check for date, first i will parse the date

Code:

myDate=$( date --date="$DATE" +%Y%m%d )


and if this date is older than system date then dont print from awk
>also i need to perform one more operation

Code:

sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alertdefinition list --id=13982 --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true | grep priority | awk -F'priority=' '{print $2}' | cut -d'"' -f2


whose output will be

Code:

3


PS: i am not good at parsing xml so i did some my own awk and cut to get priority value from xml 🙂

the about is nothing but from the priority obtained for that id and display it on console immediately

————–
so final output will be

Code:

ID=10102
NAME=APP-DS-ds_ha-140018-componentFailure-S
FIXED=false
DATE= 2013-01-29 04:58:27.6
AlDefID=13982
priority=3
.
.
.etc etc many entries will be there


i tried using the hqapi command in quotes “ inside awk but it dint work.
any help on this will be deeply appreciated. thanks

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Log file Creation

By cnrj

Hi

I have unix script which does execute some OS commands and DB Commands. I would like to create log file for each command execution, Could some one advise how do we create log file.

Example Script:


###########################################################################
ORACLE_SID=ERS11G
ORACLE_HOME=/u03/app/oracle/product/11.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID ORACLE_HOME PATH LD_LIBRARY_PATH
###################################### Defining the Paths####################
SOURCETYPE=$1
INPUTFILESPATH=/ersdg3/ERS/TEST/RIO/files
BASEPATH=/ersdg3/ERS/TEST
ARCHIVEPATH=$BASEPATH/$SOURCETYPE/archive
CONTROLFILEPATH=$BASEPATH/$SOURCETYPE/control
AUDITFILENAME=${SOURCETYPE}_AUDIT_FILE.TXT
SOURCELOADER=${SOURCETYPE}_SOURCE_LOADER
AUDITCONTROLFILENAME=${SOURCETYPE}_REC_CNT.ctl
SOURCECONTROLFILENAME=$SOURCETYPE.ctl
SOURCECONTROLFILENAMENEW=${SOURCETYPE}_NEW.ctl
SOURCETABLENAME=ERS_${SOURCETYPE}_SRC
ARCHAUDITFILEPATH=${ARCHIVEPATH}/auditfiles
USERID=ETL_ERS
PASSWORD=ETL_ERS
SCHEMA=ERS11G
#####################################End of Paths###########################
cd $INPUTFILESPATH
################# Entry into Audit Table####################################
if [ -f *.LOG ]
then
sqlplus -s -L ETL_ERS/ETL_ERS@ERS11G<<EOF
set feedback off heading off
#exec ETL_LOG.P_LOG_START_PROCESS(trunc(sysdate),'${SOURCELOADER}','ETL_SRC');
exit;
EOF
else
echo "Files doesnt exist"
exit;
fi
####################End of Entry into Audit Table##########################
ls *.LOG >FILE.LIST
###################Check whether Audit file Exists#########################
if [ -f $AUDITFILENAME ]
then
rm $AUDITFILENAME
else
touch $AUDITFILENAME
fi
#########################################################################
while read filename
do
##############Date Format for Sql Loader Script and for Directory Creation#####
filename=$filename
fname=${filename%%.*}
date1=${fname##*_}
date=`print $date1 |cut -c1-8`
dat=`print $date |cut -c7-8`
yr=`print $date |cut -c1-4`
mon=`print $date |cut -c5-6`
var01="Jan"
var02="Feb"
var03="Mar"
var04="Apr"
var05="May"
var06="Jun"
var07="Jul"
var08="Aug"
var09="Sep"
var10="Oct"
var11="Nov"
var12="Dec"
val=$( eval eval echo $var$mon )
DATE="$dat-$val-$yr"
dir=${SOURCETYPE}_${DATE}
echo $dir
############End of Date Format################################################
done <FILE.LIST


…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Sorting a CSV file by DOB

By redshine6

I have absolutaly no idea how to get this script to sort the info in Birthdays.csv by date of birth. I know the sort -n command, however i wish to sort the file birthdays.csv by DOB. How would i go about doing this?

The below script gets user info and date of birth and then puts these info a file called “birthday.csv”.
I then need to Sort “birthdays.csv” by date of birth and then display this newly sorted information. I also calculate how old each person is by today’s date. The problem i have is sorting the info in birthdays.csv by date of birth. Can someone let me know how i would do this sort?

The script is below:


#!/bin/bash

a=0
while [ $a -lt 2 ];
do
echo Please enter a first name
read firstName
echo Please enter last name
read lastName
echo Please enter phone number
read phoneNumber
echo Please enter date of birth - format dd/mm/yyyy
read dob
echo "$firstName,$lastName,$phoneNumber,$dob" >> birthday.csv
echo If you would like to add another person press 1 or enter 2 to proceed
read a
done

INPUT=./birthday.csv
OLDIFS=$IFS
IFS=","
[ -f ${INPUT} ] && while read Name Surname Telephone DOB
do
birthMonth=${DOB:0:2}
birthDay=${DOB:3:2}
birthYear=${DOB:6:4}

currentDate=`date +%d/%m/%Y`

currentMonth=${currentDate:0:2}
currentDay=${currentDate:3:2}
currentYear=${currentDate:6:4}

if [[ "$currentMonth" -lt "$birthMonth" ]] || [[ "$currentMonth" -eq "$birthMonth" && "$currentDay" -lt "$$birthDay" ]]
then
let Age=currentYear-birthYear-1
else
let Age=currentYear-birthYear
fi

echo "---------------------------"
echo "Name : $Name"
echo "Surname : $Surname"
echo "Telephone : $Telephone"
echo "DOB : $DOB"
echo "Age : $Age"
echo "---------------------------"
done < $INPUT
IFS=$OLDIFS
echo $DATE

exit 0;


Thank you in advance, all help is most appreciated.

Source: FULL ARTICLE at The UNIX and Linux Forums

Mario Limonciello: Multi-homed MythTV backend

This is the first of my non OpenWRT related posts.

I have a peculiar situation.  I have two houses that I split my life between.  I don’t want to pay for cable in both houses, but I also want access to some of the TV shows that you only get newer episodes on cable and not via Netflix/Hulu/Amazon.

So to solve this, I have set up MythTV in both houses.  Both setups run Mythbuntu 12.04.1 (www.mythbuntu.org).  In the house without cable I have a Silicondust HD Homerun.

The HD Homerun is set to record OTA content exclusively.  I get all the basic TV networks this way in that house.

In the second house I have a Silicondust HD Homerun Prime.  I’m fortunate that in that house I have Comcast, which is one of the more friendly companies with regard to copy protection.  I’m able to record pretty much everything except the premium networks like HBO and Showtime.
 

In the second house I duplicate all the OTA recording schedules but also schedule things on the other stations I care about.

Secondary House

Now to get the recordings from the second house to the first house, I had to setup a collection of scripts that run in staggered cron jobs.  The first one is on the secondary house.  I first determined which channel ID’s I needed to export from.  This can be found by looking through mythweb or by examining the database with a tool like phpmyadmin.  Look for ‘chanid’ in the ‘channels’ table.

Once I had those channels figured out I created this script.  On each daily run it will find all the recordings who’s starttime happened to be “today”.  It exports all relevant SQL data about that recording into a flat SQL file that can be imported on the primary house.

Next it creates a list of recordings that will need to be synced over to the primary house.  This list is based upon the last successful sync date from the primary house.  It only syncs all recordings between the lastrun date and “tomorrow”.  This sets it up so that if for some reason the primary backend doesn’t sync a day it will still work.  Also it’s important to sync only a handful of days because the autoexpire will be happening at different rates on the two backends.

I store all this content in the directory /var/lib/mythtv/exported-sql

sudo mkdir -p /var/lib/mythtv/exported-sql 

sudo chown mythtv:mythtv /var/lib/mythtv/exported-sql

/home/mythtv/export.sh 

#!/bin/sh

#export SQL
chanid=”2657 2659 2622″
DIRECTORY=/var/lib/mythtv/exported-sql/
BIGGEST_DATE=`find $DIRECTORY -maxdepth 1 -name ‘*.sql’ | sort -r | head -1 | sed ‘s,.*exported-,,; s,.sql,,’`
for chan in $chanid;
do
[ -n “$where” ] && where=”$where or”
[ -n “$BIGGEST_DATE” ] && date=” and starttime > ‘$BIGGEST_DATE 00:00:00′”
where=”$where (chanid=’$chan’$date)”
done
CONFIG=$HOME/.mythtv/config.xml
DATE=`date ‘+%F’`
if [ “$DATE” = “$BIGGEST_DATE” ]; then
echo “Already ran today, not running SQL generation again”
else
db=`xpath  -q -e ‘string(//DatabaseName)’ $CONFIG 2>/dev/null`
user=`xpath  -q -e ‘string(//UserName)’ $CONFIG 2>/dev/null`
pass=`xpath  -q -e ‘string(//Password)’ $CONFIG 2>/dev/null`
host=`xpath  -q -e ‘string(//Host)’ $CONFIG 2>/dev/null`
fname=/var/lib/mythtv/exported-sql/exported-$DATE.sql
mysqldump -h$host -u$user -p$pass $db recorded recordedseek recordedrating recordedprogram recordedmarkup recordedcredits –where=”$where” –no-create-db –no-create-info > $fname
fi


#generate a recordings list
lastrun=/home/mythtv/lastrun
tomorrow=$(date –date=”tomorrow” ‘+%Y%m%d’)
if [ -f $lastrun ]; then
        tmp=$(cat $lastrun)
else
        tmp=$tomorrow
fi
while [ “$tmp” != “$tomorrow” ]
do
        test_dates=”$test_dates $tmp”
        tmp=$(date –date=”1 day $tmp” ‘+%Y%m%d’)
done
test_dates=”$test_dates $tomorrow”
for date in $test_dates;
do
        for chan in $chanid;
        do
                from=”$from /var/lib/mythtv/recordings/${chan}_${date}*”
        done
done
ls $from 2>/dev/null | tee /var/lib/mythtv/exported-sql/recordings-list
Next I set up rsync to export my /var/lib/mythtv directory (read only) and my lastrun successful (write only).

/etc/rsyncd.conf

max connections = 2
log file = /var/log/rsync.log
timeout = 300

[mythtv]
comment = mythtv
path = /var/lib/mythtv
read only = yes
list = yes
uid = nobody
gid = nogroup
auth users = rsync
secrets file = /etc/rsyncd.secrets

[lastrun]
comment = last rsync run
path = /home/mythtv/
write only = yes
read only = no
list = no
uid = mythtv
gid = mythtv
auth users = rsync
secrets file = /etc/rsyncd.secrets
Last thing to do on the secondary house is to set up the crontab to run at night.  I set it for 11:05 PM every day.  It should only take a 10-15 seconds to run.
5 23 * * * /home/mythtv/export.sh
Because of the way this all works, I decide to leave my secondary house backend on all the time.  

Primary House

Now in my primary house I need to sync recordings, SQL data, and then update the last successful run at the secondary house.

/home/mythtv/import.sh

#!/bin/sh

domain=rsync@address
sql_directory=/home/mythtv/sql
recordings_directory=/var/lib/mythtv/recordings
password_file=/home/mythtv/password-file
lastrun=/home/mythtv/lastrun

sync_recordings()
{
today=$(date ‘+%Y%m%d’)
from=$(cat $sql_directory/recordings-list | sed “s,/var/lib/mythtv,$domain::mythtv,”)
RET=30
while [ $RET -eq 30 ]; do
#rsync -avz –partial –timeout 120 –progress $from –password-file=password-file $recordings_directory
rsync -av –partial –timeout 120 –progress $from –password-file=$password_file $recordings_directory
RET=$?
done
echo “rsync return code: $?”
[ $RET -ne 0 ] && exit 1
echo “$today” > lastrun
rsync -avz –password-file=password-file lastrun $domain::lastrun/
}

sync_sql()
{
rsync -avz $domain::mythtv/exported-sql/* –password-file=$password_file $sql_directory
}

insert_sql()
{
CONFIG=$HOME/.mythtv/config.xml
db=`xpath  -q -e ‘string(//DatabaseName)’ $CONFIG 2>/dev/null`
user=`xpath  -q -e ‘string(//UserName)’ $CONFIG 2>/dev/null`
pass=`xpath  -q -e ‘string(//Password)’ $CONFIG 2>/dev/null`
host=`xpath  -q -e ‘string(//Host)’ $CONFIG 2>/dev/null`
old_host=supermario
new_host=kingkoopa
for fname in $(find $sql_directory -maxdepth 1 -name ‘*.sql’);
do
if [ ! -f ${fname}.imported ]; then
cat $fname | sed “s,${old_host},${new_host},g; s,INSERT INTO, INSERT IGNORE INTO,g” > ${fname}.imported
mysql –host=$host –user=$user -p$pass $db < ${fname}.imported
fi
done
}

suspend()
{
sudo /usr/local/bin/setwakeup.sh $(date –date=’18:00′ ‘+%s’)
sudo pm-suspend
}

mythfilldatabase
sync_sql
sync_recordings
insert_sql
#suspend
I’m careful about the order I do things.  The SQL has to get inserted last in case for some reason the recordings fail to sync or don’t all sync while i’m watching.
I currently don’t suspend afterwards due to some instability on my system, but I have been experimenting with that too.  If S3 is reliable you can configure the setup to suspend after the sync is done and wake up next time you need to use it or record from it.
I set the cronjob to run at midnight every day on the primary backend.
0 0 * * * /home/mythtv/import.sh

Source: FULL ARTICLE at Planet Ubuntu

DATE TIME formating

By nex_asp

can anyone one help me….to make date and time format…to following format for my file

Code:

Code:

DATE TIME DD- MON- YEAR 24 Hours


I have a need of format like this

12-Jan-2012 in one column, then time in 24 Hours in another column….please help…me…

currently we are upgrading our database….kindly help to make standard format…

our database containing format like this

Code:

Code:

DD-MON-YEAR MON-DAY-YEAR YEAR-MON-DAY DD/MON/YEAR MON/DAY/YEAR YEAR/MON/DAY


some files containing month name, some number…

Code:

and time format
both 12 and 24 hours are mixed


script has to read current format of date and time and then write to new file with standard format

Awaiting for help…

here is my data

Code:

DATE,PR,ST,ONC,NOD
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 06:00:00 AM,748,1,43,1
25/1/1979 06:00:00 AM,748,1,43,1
20/1/1979 06:00:00 AM,748,1,43,1
31/9/1979 06:00:00 AM,748,1,43,1
20/1/1979 06:00:00 AM,748,1,43,1
31/9/1979 06:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,749,2,44,2
25-Jul-1979 03:00:00 AM,750,3,45,3
Feb-08-1988 12:05:00 PM,751,4,46,4
Feb-08-1988 12:05:00 PM,752,5,47,5
08-Feb-1988 18:00,753,6,48,6
08-Feb-1988 18:00,754,7,49,7
25-1-1979 06:00:00 AM,748,1,43,1
20-1-1979 06:00:00 AM,748,1,43,1
1-15-1979 06:00:00 AM,748,1,43,1
2-19-1979 06:00:00 AM,748,1,43,1


those who know please do favour for me…

Source: FULL ARTICLE at The UNIX and Linux Forums

DATE TIME formatting

By nex_asp

can anyone one help me….to make date and time format…to following format for my file

Code:

Code:

DATE TIME DD- MON- YEAR 24 Hours


I have a need of format like this

12-Jan-2012 in one column, then time in 24 Hours in another column….please help…me…

currently we are upgrading our database….kindly help to make standard format…

our database containing format like this

Code:

Code:

DD-MON-YEAR MON-DAY-YEAR YEAR-MON-DAY DD/MON/YEAR MON/DAY/YEAR YEAR/MON/DAY


some files containing month name, some number…

Code:

and time format
both 12 and 24 hours are mixed


script has to read current format of date and time and then write to new file with standard format

Awaiting for help…

here is my data

Code:

DATE,PR,ST,ONC,NOD
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 18:00,748,1,43,1
7/19/1979 06:00:00 AM,748,1,43,1
25/1/1979 06:00:00 AM,748,1,43,1
20/1/1979 06:00:00 AM,748,1,43,1
31/9/1979 06:00:00 AM,748,1,43,1
20/1/1979 06:00:00 AM,748,1,43,1
31/9/1979 06:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,748,1,43,1
25-Jul-1979 03:00:00 AM,749,2,44,2
25-Jul-1979 03:00:00 AM,750,3,45,3
Feb-08-1988 12:05:00 PM,751,4,46,4
Feb-08-1988 12:05:00 PM,752,5,47,5
08-Feb-1988 18:00,753,6,48,6
08-Feb-1988 18:00,754,7,49,7
25-1-1979 06:00:00 AM,748,1,43,1
20-1-1979 06:00:00 AM,748,1,43,1
1-15-1979 06:00:00 AM,748,1,43,1
2-19-1979 06:00:00 AM,748,1,43,1


those who know please do favour for me…

Source: FULL ARTICLE at The UNIX and Linux Forums

Help to reduce time of archiving

By arrals_vlhi all,

i have written the following script that does this work:
1. copy large logs files from one server to another.
2. then unzip this files and extraxt from these large https logs only those fields that are neccesary.
3. then archive the extracted logs to new files.

BUT the problem is that all this proccess is TOO SLOW and it takes much time to be completed.
Could you please take a look at my script and suggest me any improvement?

Thank you in advance!!

#!/bin/bash
set -x

FINALDIR=/data/media/LOGS/archive/_cdrc2

DATE=`date +%Y%m%d`
#echo “`date +’%Y/%m/%d %H:%M:%S’` Starting getting CDR‘s”

mkdir /data/media/LOGS/archive/logs2/$DATE/
/bin/chmod 750 /data/media/LOGS/archive/logs2/$DATE
/usr/bin/setfacl -m g:ITdep:rx /data/media/LOGS/archive/logs2/$DATE
scp httplogs@192.168.70.123:/data/backup/cdr/hotcdr/MEGAFLOW*$DATE* /data/media/LOGS/current/logs2/

cd /data/media/LOGS/current/logs2

for i in `ls *.gz`
do
gunzip $i
a=`echo $i | cut -d’.’ -f1-2`
awk -F ‘t’ ‘{ print $2″t”$4″t”$6″t”$16″t”$17″t”$18″t”$22″t”$37″t”$43″t”$44 }’ $a >> LOGS_Extracted_CDR_$DATE #extract selected fields from the CDR and append them to new cdr file
7za a -bd -mfb=255 $a.7z $a
rm -f $a
mv $a.7z /data/media/LOGS/archive/logs2/$DATE/
done

7za a -bd -mfb=150 LOGS_Extracted_CDR_$DATE.7z LOGS_Extracted_CDR_$DATE #compress with 7za the new cdr file
rm LOGS_Extracted_CDR_$DATE -f
mv LOGS_Extracted_CDR_$DATE.7z $FINALDIR
Source: The UNIX and Linux Forums

Find the occurence of particular string in log file

By maddyroxI have a log file which looks like this:

[2012-12-04 13:54:15,744]

I have to extract DATE and number of times the keyword STATUS is shown on each date.

Input is : [2012-12-04 13:54:15,744]
Output: in excel file, Column1(date) Column2(Number of occurences)
My excel file should also contain all the dates, if on any particular day, STATUS keyword is not found, it will show count as 0

Please help me ASAP. I am in very urgent need of this shell script.
Source: The UNIX and Linux Forums

Working with files that are named with a timestamp

So I have a script that runs an ls on a given directory and looks for files with a timestamp that has the current hour in it and then does work with the files that it discovers

Code:
DATE=`date +’%y%m%d%H’`
HOSTIS=`hostname`
#EMAIL NOTIFICATION ALS
EMAIL=address@server.com
#

if [ $HOSTIS = ‘serverhostname’ ]; then
TOHOST=’destination_address@destination_server.com’
else
#This is for the test server
TOHOST=’test_address@test_server.com’
fi

for i in `ls /transfer |grep $DATE`
do

sftp -vvv $TOHOST 2>&1 | tee /homedir/user/debug.out
Source: The UNIX and Linux Forums