1826350 Members
4492 Online
109692 Solutions
New Discussion

Script Problem

 
Jeffrey F. Goldsmith
Super Advisor

Script Problem

I have a script that runs every night that gives me system information and helps to clean out old temp files. The script runs fine on my L2000 server w/ HP-UX 11.0 but is giving me some trouble on my rp3440-4 w/ HP-UX 11.23 server. Has the touch command changed with the newer version of UNIX? When touch command is used on the folders in the /tmpspool some how the folders are changed to files.

Here is a copy of the script.

root: /root ==> more genadmin
#!/bin/ksh

# mail lvol list to root
/usr/bin/bdf

# back up lvol config; mail output to root
/etc/vgcfgbackup /dev/vg00
/etc/vgcfgbackup /dev/vg01
#
#
# Check out Swap Space:
swapinfo -tam
#
#
# Check the size of the "mib2agt" program:
ps -efl|grep mib2agt
#
#
# remove old files from ifas tmp directories, /tmpspool
touch /apps/ifas/admin/tmp
touch /apps/ifas/bsi/tmp
touch /apps/testifas/admin/tmp
rm -r `find /apps/ifas/admin/tmp -depth -mtime +1`
rm -r `find /apps/ifas/bsi/tmp -depth -mtime +1`
rm -r `find /apps/testifas/admin/tmp -depth -mtime +1`

touch /tmpspool/.stdlist /tmpspool/err /tmpspool/download /tmpspool/fxpress /tmp
spool/payrpts /tmpspool/payxtracts /tmpspool/workcomp
rm -rf `find /tmpspool -mtime +2`

# clear out the "printutl" folder (used by the printer called "transfer")
touch /home/printutl
rm -rf `find /home/printutl -mtime +2`

# extract the performance data for today
# cd /home/root
# rm rxlog
# fn=`date +%Y%m%d`
# /opt/perf/bin/extract -xt d -gp
# mv rxlog ${fn}.prf
# /opt/contrib/bin/VgCollect > /home/root/kiska.xvg

# deal with syslog
# cd /var/adm
# mv syslog syslog.$fn
# rm -rf `find ./syslog.* -mtime +14`
# kill -HUP `cat /var/run/syslog.pid`
root: /root ==>
4 REPLIES 4
Victor Fridyev
Honored Contributor

Re: Script Problem

Hi,

The touch command has not changed, I'm afraid the directories don't exist befor the command runs.

You can change this by running the script commands manually.

BTW, I'm not sure that the way you run rm commands is the best. If find commands produce long lists, the script can have problems.
Try to use:

find dirname -mtime +2| xargs rm -f

HTH
Entities are not to be multiplied beyond necessity - RTFM
Jonathan Fife
Honored Contributor

Re: Script Problem

Perhaps the folders didn't exist before the first time you ran the script, in which case touch would indeed create files.
Decay is inherent in all compounded things. Strive on with diligence
Dennis Handly
Acclaimed Contributor

Re: Script Problem

If you need to conditionally create directories you can use mkdir -p before the touch.

Also, you should replace your "rm ... find" by something like the following:
find /home/printutl -mtime +2 -exec rm -rf +
Reshma Malusare
Trusted Contributor

Re: Script Problem

Hi Jeffrey,
1.Touch command:Touch updates the access, modification, and last-change times of each argument.The file name is created if it does not exist. If no time is specified the current time is used.
So,here i think instead updating its creating files.You can use it with following option:
-c Silently prevent touch from creating the file if it did not previously exist.

Regards,
Reshma