These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Chown & Chmod Cron task on the new forum.
Hi
I wanna create a cron task for different joomla website under virtualmin i manually do this following command via ssh
cd /home/domainname1
sudo chown -R -v apache:apache public_html
sudo chown -v user1:group1 public_html
cd /home/domainname1/public_html
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
and for a second domain for example
cd /home/domainname2
sudo chown -R -v apache:apache public_html
sudo chown -v user2:group2 public_html
cd /home/domainname2/public_html
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
i wanna run this weekly
I have no idea how to process , create a script or type this different command after create a new cron task in webmin
Thanks for your help
Howdy,
I'd make the above into a script, and then call that script from cron.
-Eric
Thank you Eric
I have no idea of the structur of the script need. I was reading a few php script on the net but the syntax is far of the ssh command line i use. Can i paste straight like this in a file chown.php ?
#!/bin/bash
cd /home/domainname1
sudo chown -R -v apache:apache public_html
sudo chown -v user1:group1 public_html
thanks
philippe
Yup, that should work just fine! Though, it looks like you have a trailing slash behind the word "bash", you probably don't want that. But that should otherwise work just fine.
-Eric
Hello Eric I done my first test of my first script using the following code
#!/bin/bash -x
cd /home/walpy/
sudo chown -R -v apache:apache public_html
sudo chown -v walpy:walpy public_html
my script chown is root:root 755, path = /etc/chown
the output when running the script in Webmin manually i have this error in the output
When i launch this script /etc/chown from my pc in command line ,there is no issue and all the files are chown correctly Im logued as root in webmin.
http://img840.imageshack.us/img840/7572/crontask.th.png
You may want to just always run that script as root, and not use "sudo" in the script. That would be a simple way to fix the problem you're seeing.
-Eric
Simple and works thanks a lot Eric Really Helpfull
The code finally used
#!/bin/bash -x
cd /home/domainname/
chown -R -v apache:apache public_html
chown -v user:group public_html