Quantcast
Channel: Admins Goodies » macosxserver
Viewing all articles
Browse latest Browse all 10

Setting up a cron job that does a chmod/chown

$
0
0

Question

I would like to set up a cron job that recusively does a chmod/chown on a directory (the dropbox directory).

This works when I execute the commands manually like:

sudo chown -R $USER ~/Dropbox
sudo chmod -R u+rw ~/Dropbox

I tried to convert it into a cron job like this:

10      *       *       *       *       sudo chown -R $USER ~/Dropbox

But it doesn’t seem to do the job.

How to do this?

Asked by tvgemert

Answer

You want your root cron script (edit by running sudo crontab -e) to be:

 55 * * * * /bin/chown -R somename /home/somename/Dropbox && /bin/chmod u+rw /home/somename/Dropbox

Assuming the user is named somename and that /home/somename/Dropbox is the full path of your Dropbox directory. As root user, ~ goes to /root.

Answered by dr jimbob

Viewing all articles
Browse latest Browse all 10

Trending Articles