- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help in creating shell script in hp-ux
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2008 06:07 AM
тАО01-28-2008 06:07 AM
Every hour search for specific files name formats in specified directories:
/test/dir1/dir2 search for l50*.txt.*
/test/dir1/dir3 search for l50*.txt.*
/test/dir1/dir2 search for S0**.txt.*
/test/dir1/dir3 search for S0**.txt.*
Exception l503a.txt on the /test/dir1/dir3.
And if the file exists with creation time more than an hour back from the time when scan starts an email alert should be fired to abc@test.com with information on concerned file names.
Please note: No alter should be fired for file I503a.txt in dir /test/dir1/dir3
Thanks in advance for your help and support.
Nag.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2008 06:21 AM
тАО01-28-2008 06:21 AM
Re: Need help in creating shell script in hp-ux
Pete
Pete
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2008 06:31 AM
тАО01-28-2008 06:31 AM
SolutionI'll provide the guts of your answer, just as I did to a nearly identical question by you earlier this month:
If you are looking for files modifed in the last hour, use Perl:
# perl -MFile::Find -le 'find(sub{print if -f $_ && -M _ < (1/24) && m/(l50|S0).*\.txt/},"/test")'
This finds files in the specified directory that are 1/24 of a day (one hour) or less in age. This age is the *modification* age of the file. There is no such thing as a "creation" timestamp in Unix.
If you would like to use pure shell:
# touch -amt 01101530 /tmp/myref
# find /home/myref -type f -newer /tmp/myref -name "abc*"
Of course, the "problem" in the shell solution is that you have to perform a touch of a reference file to create the one-hour delta everytime you want to search! The Perl solution obviates that.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2008 07:03 AM
тАО01-28-2008 07:03 AM
Re: Need help in creating shell script in hp-ux
Thanks a lot for your inputs, I appreciate your speedy reply, i would try this out on the test server, and would update you about the same
thanks
Nag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2008 01:13 AM - edited тАО01-12-2014 11:07 AM
тАО01-30-2008 01:13 AM - edited тАО01-12-2014 11:07 AM
Re: Need help in creating shell script in HP-UX
>Every hour search for specific files name formats in specified directories:
If you don't care about the first time for the "hour back" limitation you can do:
DIR=/test/dir1
RF=ref_file
if [ ! -f ${RF}2 ]; then
touch ${RF}2
fi
mv ${RF}2 ${RF}1
touch ${RF}2 # for next time
find $DIR/dir2 \( -name "l50*.txt.*" -o -name "S0**.txt.*" \) ! -newer ${RF}1 > notify_file
find $DIR/dir3 \( -name "l50*.txt.*" -o -name "S0**.txt.*" \) ! -newer ${RF}1 |
grep -v l503a.txt >> notify_file
if [ -s notify_file ]; then
mailx -s "found files" abc@test.com < notify_file
fi
>And if the file exists with creation time
You can only find modification times.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2014 01:15 AM
тАО01-12-2014 01:15 AM
Re: Need help in creating shell script in hp-ux
Hi i am an SAP basis consultant
i require an script to run in my system to take the files within the test folder and send it to my mail
the same issue as yours but for me age limit is okay
it would be better every hour i get an mail intimation of the files within the specified folder
kidnly help me out with an script that helps to ful fil my needs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2014 11:12 AM
тАО01-12-2014 11:12 AM
Re: Need help in creating shell script in HP-UX
>to take the files within the test folder and send it to my mail
I'm not sure why you can't figure this out from the various posts. They show how to use find and a reference file.
And how to mail the results.
>every hour I get an mail intimation of the files within the specified folder
You should set this up in crontab.