Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-29-2009
Registered User
 

Join Date: Mar 2009
Posts: 3
Permission denied problem

I am trying to tidy our server and write cron to keep it tidy.

We took on a third party to do some work last year. They were given their own UID/pwd so that they would have limited access. Part of what they wrote created an archive file at the end of every day.

A year on and we don't want to keep all the archives. I am trying to write a line that will delete all files older than 30 days from the folder (that I can insert into our standing monthly cronjob).

Find –name “*.html” –mtime +30 –exec rm –f {} \;

This command works only when I have gone in under the the old UID. If I try to run it from the standard UID I get 'Permission denied'. So obviously cron won't work for me yet.

What should I try next to get around this file permission problem?

thx

RexJ
Sponsored Links
  #2 (permalink)  
Old 03-29-2009
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,659
There is a standard solution to this: use the "root" user to access every file, regardless of who owns it.

The other possibility would be to put your cron job into the crontab of the UID which owns the files. Every user has a separate crontab, which is a readable ASCII file. The location depends on the UNIX you are using, for instance in IBMs AIX the crontabs are located in "/var/spool/cron/crontabs/<user>" where "<user>" is the user accounts name.

Your "find" command seems to be correct save for a missing starting directory:

find <some_start_dir> –name “*.html” –mtime +30 –exec rm –f {} \;

but keep in mind that a process started from cron does not inherit the environment like a process started from an interactive shell does. if you write "find" instead of "/usr/bin/find" chances are you get a "command not found" error, because the PATH variable, which you have probably set in your login shell is not set for cron jobs. (This is, btw., the absolute number-1-error in this and the Shell-Programming-and-Scripting forum.)

I hope this helps.

bakunin
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ssh permission denied gefa AIX 3 12-04-2008 10:52 AM
Permission Denied howeezy UNIX for Dummies Questions & Answers 0 09-14-2005 10:52 AM
tar : permission denied big123456 UNIX for Advanced & Expert Users 0 09-09-2005 05:32 AM
BSD Permission Denied Problem Phyber UNIX Desktop for Dummies Questions & Answers 2 03-18-2002 01:24 AM
permission denied?? justchillin UNIX for Dummies Questions & Answers 6 08-10-2001 04:19 PM



All times are GMT -4. The time now is 12:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0