Script problems in hp unix systems


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script problems in hp unix systems
# 1  
Old 07-27-2012
Script problems in hp unix systems

test.sh
--------------

Code:
#This script deletes the temporary files created on the server when the user opens the output files
#

FILE_PATH=$1
P_FILE_PATH=$2
FRQ=$3
#FRQ=`expr $FRQ*60*24 | bc`
#FRQ= 60

echo $FILE_PATH
echo $P_FILE_PATH
echo $FRQ
if [ -n $FILE_PATH ] 
then
    find $FILE_PATH  -mmin +60 -exec  rm -f  {} \;
    echo in file path
fi
if [ -n $P_FILE_PATH ] 
then
    find $P_FILE_PATH  -mmin +60 -exec  rm -f  {} \;
    echo in p file path
fi


The above code is not working in hp ux systems.Do i need any changes in the above script.Smilie
Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 07-27-2012 at 12:01 PM..
# 2  
Old 07-27-2012
-mmin is a GNU-only option, which makes this trickier.

There's a more standard option for hours, but what I'd do instead is run this every 60 minutes in a cron job:

Code:
if [ ! -f /tmp/timestampfile ]
then
        touch /tmp/timestampfile
fi

find /path/to/files -type f '!' -newer /tmp/timestampfile -exec echo rm '{}' ';'
touch /tmp/timestampfile

That way, it doesn't have to calculate 'n minutes ago', it can just compare to the timestamp of a file in /tmp/.

Remove the echo once you're sure it does what you want.
# 3  
Old 07-27-2012
@Corona688 Suggested change to the first time condition to prevent the script deleting all files on the first iteration.

Code:
if [ ! -f /tmp/timestampfile ]
then
        touch /tmp/timestampfile
        exit    # Do nothing
fi

find /path/to/files -type f '!' -newer /tmp/timestampfile -exec echo rm '{}' ';'
touch /tmp/timestampfile

This User Gave Thanks to methyl For This Post:
# 4  
Old 08-02-2012
Hi thanks for the reply.

Is there any other alternative instead of using cron job and awk to delete files older than 30 minutes.
# 5  
Old 08-02-2012
Certainly. Try mine -- it doesn't use awk at all.
# 6  
Old 08-02-2012
@arjunbodduuxlx
The cron solution is the best solution based on the information supplied. This assumes that you don't want to make ypur HP-UX non-standard by downloading GNU utilities which could well make your server unsupportable by HP and affect existing scripts.


Please be consistent. Post #1 implies 60 minutes but post #4 implies 30 minutes.

Personally I would run this sort of cleanup once-a-day or once-a-week but definitely not every 30 minutes unless there is a very good reason.
# 7  
Old 08-02-2012
touch often can take a parameter to specify the time (at least by POSIX standard, not sure about HP-UX). you can touch a file with a time in the past, and then use find -newer
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix Shell Script to ping systems & make a log

Hi, I need to ping all the systems in my network and then create a log for the ones, from where I successfully get the ping-response (ICMP packet). Now, I've used the ping command successfully, but am unable to use 'grep' command to locate the IPs for which the ping was successful (so that I... (5 Replies)
Discussion started by: psychoTHEIST
5 Replies

2. UNIX for Dummies Questions & Answers

unix Operating Systems 5

Hi :) I have unix Operating Systems 5 I need working for user logout befor 10 minutes,In the case that he is not active :o what do I do? :rolleyes: (4 Replies)
Discussion started by: fakhwork
4 Replies

3. UNIX for Dummies Questions & Answers

Monitoring Unix systems

I am looking for a commercial tool that will give me -UNIX Monitoring performance solution+ reports on CCV format. (as perfmon on windows machines). The tool must have following counters per PROCESS: Page Faults/sec Virtual Bytes % Processor Time Handles count Threads count... (19 Replies)
Discussion started by: gen4ik
19 Replies

4. UNIX for Dummies Questions & Answers

Notebook UNIX systems

Hy folks, I was wondering what is best unix system for notebook (laptop) computers. Older or newer, faster or slower? What is you opinion and experiance with unix on notebook?v (6 Replies)
Discussion started by: R@LE
6 Replies

5. AIX

PPE/POE problems on AIX 5.2 on p690 systems

We have PPE/POE problems on a 32 PE p690 system. After upgrading to the latest AIX 5.2 (ML 05) POE/PPE environment on a p690, we've noticed that mpi jobs could not start. I've trace the problem in the communication of poe client routines and the pmdv4 (/etc/pmdv4) partition manager on our... (0 Replies)
Discussion started by: miket
0 Replies

6. IP Networking

MRTG in Unix Systems

Hi, I need help to discovery the correct MIB to monitoring CPU, Memory and Hard Disc in Unix. I get any MIB in the internet, but donīt work. Anybody help-me? Thanks. Marcio Dunder Perin (2 Replies)
Discussion started by: dunder
2 Replies

7. SCO

Sharing unix drives from two unix systems

I have two SCO openserver systems, 1 in the US and 1 in the UK. I am setting up a vpn to connect the two local networks that also have windows pc's on them. Is there a way that either unix system can see the hard drive on the other unix system so that I can share data between them. I run a cobol... (1 Reply)
Discussion started by: rongrout
1 Replies

8. UNIX for Dummies Questions & Answers

distributers of unix systems

Well i've been looking for some unix systems to download but with all the technical stuff they talk about on the sites i think that it would be betterif i just bought oneat a store so it comeswith directions and stuff, but is there any unix system that will coincidentally run with MS-dos mode? and... (1 Reply)
Discussion started by: shag134
1 Replies

9. Filesystems, Disks and Memory

firewall for unix systems

I was wondering if anyone knew of any good firewall softwares to run on open bsd. I'm currently running ip chains but I'm looking for easier to configure. thanks (1 Reply)
Discussion started by: shadieshad
1 Replies

10. News, Links, Events and Announcements

eBay Unix systems

I should add a disclaimer: I am not affiliated with the sellers in any way, nor do I have any more knowledge than any other person reading the description about the item. This is simply for your reference. I see a good number of people wanting a SPARC system to play with, and even more that... (1 Reply)
Discussion started by: LivinFree
1 Replies
Login or Register to Ask a Question