- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to sequence log files
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
Forums
Discussions
Discussions
Discussions
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
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
05-20-2004 10:19 PM
05-20-2004 10:19 PM
I have a script for sequencing log files from 00 to 59 using:
27 typeset -Z2 N
30 for F in $FILE_LIST
31 do
32 (( N=(N+1)%60 ))
33 mv ${F} $DEST/${N}${F}
34 done
When I run it however I get the following:
./sequence.sh[32]: 08: The specified number is not valid for this command.
Any ideas?
Many thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2004 10:35 PM
05-20-2004 10:35 PM
Re: script to sequence log files
You might want to look into the Logrotate tool:
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/logrotate-2.5/
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2004 10:46 PM
05-20-2004 10:46 PM
Re: script to sequence log files
Try this patch or the latest version of it.
PHCO_29816
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 12:22 AM
05-21-2004 12:22 AM
Re: script to sequence log files
(( N=(N+1)%60 ))
into :
N=$(( (N+1) % 60 ))
should work...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 12:29 AM
05-21-2004 12:29 AM
Re: script to sequence log files
thanks for replies so far.
Mark, I think you may be right with that, one system was patched 3 weeks ago (script does not work on this system now), works fine on the un-patched systems.
Maybe changing "typeset" could do the job? any ideas?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 12:34 AM
05-21-2004 12:34 AM
Re: script to sequence log files
If you are having problems though, the solution, as is so often the case, is to simplify. You could go
(( N=N+1 ))
[[ $N -gt 60 ]] && N=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 12:37 AM
05-21-2004 12:37 AM
Re: script to sequence log files
This worked for me:
For "(( N=(N+1)%60 ))" i did
let N=$N+1
let N=$N/60
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 12:57 AM
05-21-2004 12:57 AM
Re: script to sequence log files
That's nearly what I need, I have to keep the sequence numbers to 2 digits though.
Is there another way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 01:04 AM
05-21-2004 01:04 AM
Re: script to sequence log files
If you want to keep it really simple (and nasty) then add this ugly bit in too
(( N=N+1 ))
[[ $N -gt 60 ]] && N=0
[[ $N -le 10 ]] && N="0$N"
Horrible isn't it but if you're having problems why not make it ugly but working in my view :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 02:29 AM
05-21-2004 02:29 AM
Re: script to sequence log files
27 #typeset -Z2 N
30 for F in $FILE_LIST
31 do
32 (( N=N+1 ))
33 [[ $N -gt 60 ]] && N=0
34 [[ $N -le 10 ]] && N="0$N"
./sequence.sh[32]: 09: The specified number is not valid for this command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 02:54 AM
05-21-2004 02:54 AM
SolutionI think I have your code working. I think the trick is around the typeset command and the octal problem mentioned. I got it to work by using another variable to calculate the number, and then setting the variable N to that number.
Something like this:
typeset -Z2 N
T=0
for F in $FILE_LIST
do
(( T=(T+1)%60 ))
N=$T
mv ${F} $DEST/${N}${F}
done
It looks like your arithmetic expression works, but not with a variable where you have the typeset for -Z2.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2004 03:01 AM
05-21-2004 03:01 AM
Re: script to sequence log files
for F in $FILE_LIST
do
(( N=N+1 ))
[[ $N -gt 60 ]] && N=0
[[ $N -le 10 ]] && N="0$N"
Hope that should work.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2004 07:43 PM
05-23-2004 07:43 PM