Who can help me with a specific chmod cron job?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Who can help me with a specific chmod cron job?
# 1  
Old 04-28-2009
Who can help me with a specific chmod cron job?

Hi,

I put a blog on the web for a school project where pupils can post but one thing is not working properly: Photos are not being displayed because the rights of newly uploaded files are always automatically set to 600 by the server (the folder rights are set to 775). So I wrote the following cron jobs for the 3 folders concerned:

* * * * * chmod 666 /www/aublg/blog/userfiles/images
* * * * * chmod 666 /www/aublg/blog/userfiles/flash
* * * * * chmod 666 /www/aublg/blog/userfiles/documents

However, nothing changed: neither the old nor any newly uploaded photos were displayed (not even in the preview mode of the blog). Do these jobs only refer to the folders but not to the files in them? What do I have to write/ add to set every newly uploaded file to 666 (immediately, if possible, so they will already be displayed in preview mode)? It would be great if someone could help me with the exact script. (Without the possibility of uploading photos, the blog would not be very interesting for kids.)
Thanks very much!

Peter
# 2  
Old 04-28-2009
Code:
chmod 666 /www/aublg/blog/userfiles/images/*

I think you want to add a /* to each of your lines of code.
# 3  
Old 04-28-2009
I agree with jim mcnamara findings. The original cron just changed the permissions of the directory but not the files within the directory.

The whole process can be one script called from cron. This untested example avoids expanding "*" to an unknown number of filenames, deals with filenames containing spaces, and will work for any number of files:

Code:
#!/bin/ksh
for DIR in "/www/aublg/blog/userfiles/images" \
   "/www/aublg/blog/userfiles/flash" \
   "/www/aublg/blog/userfiles/documents"
   do
          if [ -d "${DIR}" ]
          then
                   cd "${DIR}"
                   find . -type f -print | while read FILENAME
                   do
                            chmod 666 "${FILENAME}"
                   done
          else
                  echo "Directory missing: ${DIR}"
          fi
   done


Last edited by methyl; 04-28-2009 at 09:27 PM.. Reason: Code tags
# 4  
Old 04-29-2009
Wrongly posted here .. so removed it.

Last edited by thegeek; 04-29-2009 at 04:36 AM.. Reason: remove this please.
# 5  
Old 04-29-2009
Thank you both for your suggestions and your quick reply!

It's very strange: nothing shows any effect, although I make sure each time there are no misspellings or any other errors in the string. I tried everything I could think of: adding /*, /*.*, even /$newfile (I saw that somewhere in the documentation of another blog), I copied methyl's script into the crontab file, set the .bash_history and .viminfo files to 777 (they had 600): nothing worked, the rights of the images in the file concerned stay unchanged (600), every newly uploaded image gets the same rights and still nothing is displayed. What could be the reason for this? Do you have any other suggestions?

Peter
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. UNIX for Advanced & Expert Users

Run A Job in Cron On A Specific Day Excluding Holidays

Hi, I want to run a job in cron on a specific date(say 25th of every month) excluding holidays. Can anyone provide some hints to do this? Thanks for any inputs. (1 Reply)
Discussion started by: sktkpl
1 Replies

5. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

6. Shell Programming and Scripting

create a chmod cron job help please

hi all, I'm so embarrasingly new; apologies. So here's my dilemma; files are being uploaded to the server via a php script... this is therefore assigning ownership to 'nobody' rather than the account 'user'. It's screwing with the permissions and then the owner can't ftp download images... (2 Replies)
Discussion started by: sirj
2 Replies

7. UNIX for Dummies Questions & Answers

CRON usage for CRON job

can anybody explain the usage of CRON for adding a cron job. please provide an example also for better understanding !!! Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

8. UNIX for Dummies Questions & Answers

cron job from specific folder

i'd like to be able to run a cron job from a specific folder /var/www/html a php script which imports rss feeds i created a simple shell script cd /var/www/html php -q import.php webmin says it executed correctly, but when i check the site, nothing has happened what am i doing... (1 Reply)
Discussion started by: sanchoquixote
1 Replies

9. UNIX for Dummies Questions & Answers

Cron Job

Hi everybody ....I am trying to write a cron job for event based subscription for a tool called Microstrategy...if anybody have idea about this please help me... Thanks in advance ark (7 Replies)
Discussion started by: arksal
7 Replies

10. UNIX for Dummies Questions & Answers

Cron JOB

I have a cron job that ran for 3 months; all the suden, it stops working. There were no changes in the script. Is there away that I can find out why? can someone with root permission disable my cron-job? Is there away that I can look into the system to see who may have done that? My cron job... (1 Reply)
Discussion started by: bobo
1 Replies
Login or Register to Ask a Question