- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: rm : permission denied ?
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
тАО12-19-2002 01:21 PM
тАО12-19-2002 01:21 PM
rm : permission denied ?
I've been asked to look at a script to see why a lock file every now and then can't be removed.
The line of code from the script is pretty straight forward. A user xxadmin creates the lock and then , when the ftp process is finished removes the file he created
############################################
# Remove pincab_transfer locking mechanism #
############################################
remove_pincab_lock()
{
if [ -f ${PINLOCK} ]; then
rm -f ${PINLOCK} >> ${ERM} 2>&1
res=$?
if [ ${res} -ne 0 ]; then
echo " Failed to remove lock file ${PINLOCK} " >> ${ERM}
app_mesg="Failed to remove lock file ${PINLOCK}"
app_alert
else
echo " Removed lock file ${PINLOCK}" >> ${ERM}
fi
fi
}
The problem isn't just on one server. The lock file is in /tmp
drwxrwxrwx 136 root sys 55296 Dec 19 22:10 /tmp
The permissions on the file are
-rw-rw-rw- 1 xxadmin support 0 Dec 19 22:14 /tmp/pincab_lock
The output from the log is
Starting pincab_transfer (PID=3518) at 13:22:04
Created lock file /tmp/pincab.lock
Config file has been read O.K.
PING connection to 164.39.253.60 is available at 13:22:04
Found 2 new file(s) for transmission
Found 0 file(s) for re-transmission
Attempting to send 2 file(s) in total
Problems moving data from /tmp to /tmp/incab_hold
rm: /tmp/pincab.lock not removed. Permission denied
Failed to remove lock file /tmp/pincab.lock
Any ideas ?
Thanks in advance for any input
Regards
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:27 PM
тАО12-19-2002 01:27 PM
Re: rm : permission denied ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:28 PM
тАО12-19-2002 01:28 PM
Re: rm : permission denied ?
A couple thoughts:
1) Does the "Problems moving data from /tmp to /tmp/incab_hold" possibly enter into this, or do you see that at other times.
2) Can you insert a ll of the file in question into the script right after the creation and right before the move?
It's a strange one all right.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:29 PM
тАО12-19-2002 01:29 PM
Re: rm : permission denied ?
The file is created before the process then removed after checks have been made that the ftp is completed, therefore isn't actually part of the ftp
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:30 PM
тАО12-19-2002 01:30 PM
Re: rm : permission denied ?
Can you post the code where the lock file gets created?
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:32 PM
тАО12-19-2002 01:32 PM
Re: rm : permission denied ?
Thats what I was looking at also. I fetched all the logs from all the servers from today but only found one instance of the failure, so couldn't see if there was a pattern. Something to think about though
I'll put an ll in the script also
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:39 PM
тАО12-19-2002 01:39 PM
Re: rm : permission denied ?
check_pincab_running()
{
REMOVE_PINLOCK='N'
if [ -f /lock.pro ]; then
echo " Detected housekeeping is running" >> ${ERM}
exit_program
fi
if [ -f /lock.out ]; then
echo " Detected the machine is about to reboot" >> ${ERM}
exit_program
fi
if [ -f /lock.bkup ]; then
echo " Detected backup is running" >> ${ERM}
exit_program
fi
if [ -f ${PINLOCK} ]; then
echo " Detected ${PINLOCK} - assuming ${PROGRAM} already running" >> ${ER
M}
exit_program
else
(touch ${PINLOCK} 2>&1) > /dev/null
res=$?
if [ ${res} -ne 0 ]; then
echo " Failed to create pincab lock file - ${PINLOCK}" >> ${ERM}
exit_program
fi
echo " Created lock file ${PINLOCK}" >> ${ERM}
fi
The things is , it works 99% of the time , then every now and again fails
bizarre
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 01:47 PM
тАО12-19-2002 01:47 PM
Re: rm : permission denied ?
Admittedly, my scripting skills aren't the strongest but it looks good to me. I'm hoping the before and after "ll's" will give us a hint (though I think it's something a little more obtuse). You're right, it's bizarre.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 02:11 PM
тАО12-19-2002 02:11 PM
Re: rm : permission denied ?
You could perhaps add
fuser -u $PINLOCK
to your script to check if another process has locked the file.
Perhaps even
rm -f ${PINLOCK} >> ${ERM} 2>&1
while (( $? != 0 ))
do
echo "Can't remove file"
fuser -u $PINLOCK
sleep 10
rm -f ${PINLOCK} >> ${ERM} 2>&1
done
But this will hang the script until it's able to delete the file :-) Not sure if you would want to do that...
Regards,
Vincent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2002 03:02 PM
тАО12-19-2002 03:02 PM
Re: rm : permission denied ?
Just curious, keep the line
ll ${PINLOCK}
before rm -f statement in your script.
See what you would know everytime they complaied about it.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2002 12:24 AM
тАО12-20-2002 12:24 AM
Re: rm : permission denied ?
This is what I have come up with to check
exit_program
else
(touch ${PINLOCK} 2>&1) > /dev/null
ll ${PINLOCK} >> ${ERM}
And
remove_pincab_lock()
{
if [ -f ${PINLOCK} ]; then
rm -f ${PINLOCK} >> ${ERM} 2>&1
res=$?
if [ ${res} -ne 0 ]; then
ll ${PINLOCK} >> ${ERM} 2>&1
sudo fuser -u ${PINLOCK} 2>&1| tr [")"] ["\n"] | grep \( |cut -d\( -f1 | t
r [":"] ["\n"] | egrep '[0-9][0-9][0-9]?' | tr ["o"] [" "] > /tmp/pinlock.pid
for i in $( do
dpd $i >> ${ERM} 2>&1
done
echo " Failed to remove lock file ${PINLOCK} " >> ${ERM}
The dpd is a small c prog to give full details of the pid and parents
I'll wait and see
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2002 03:20 AM
тАО12-20-2002 03:20 AM
Re: rm : permission denied ?
The cuestion is the path i used was a symbolic link to a NFS mounted filesystem. I had to cd to original NFS mount point to remove the file.
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2002 06:40 AM
тАО12-20-2002 06:40 AM
Re: rm : permission denied ?
Perhaps your problem is related to /tmp mode. I've seen some system with S_ISVTX set on /tmp (ie drwxrwxrwt). In this case, anyone can create a file, but only the owner or root can delete it. From man 2 chmod :
If the mode bit S_ISVTX (sticky bit) is set on a directory, files inside the directory may be renamed or removed only by the owner of the file, the owner of the directory, or the superuser (even if the modes of the directory would otherwise allow such an operation).
Regards.