Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am in the middle of create a local FTP server and I need this script to run when the machine boots up:

#!/bin/bash
while [ 1 ];
do
chmod 2777 /home/ftp/folder;
chmod -R 777 /home/ftp/folder;
sleep 60;
done

Which is the best way to go about this?

I have tried to put it in the rc.local file but this doesn't allow the server to boot properly at all, also this script needs to be ran as sudo, if that will make a difference within the the script is ran.

Any help or ideas would be appreciated, Thanks.

share|improve this question
    
Are you sure about the "chmod -R 777".. this makes all files executable too. I'm paranoid, I don't want some description of "hey don't do: rm -rf /" turned into a script by being executable :) –  Rich Homolka Jun 7 '13 at 15:59
    
I understand that but for what I'm creating it needs to be executable. The server can only be accessed internally and each account is assigned to individuals. –  Ash King Jun 10 '13 at 11:28
add comment

migrated from stackoverflow.com Jun 7 '13 at 13:48

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

whats about using a cronjob?

put

#!/bin/bash
chmod 2777 /home/ftp/folder
chmod -R 777 /home/ftp/folder

into a script file and invoke it every minute:

sudo crontab -e

and invoke with following:

* * * * * /path/to/script.sh

further information - ubuntu wiki

share|improve this answer
    
Thanks, worked perfect! –  Ash King Jun 7 '13 at 12:33
add comment
  • Remove the loop from your script
  • Place the script into some reasonable directory (e.g. /usr/local/sbin/)
  • Place a cron job description into /etc/cron.d/ , e.g.

* * * * * myuser /usr/local/sbin/myscript

This will make your script run every minute. Then, to be completely on the safe side, you'd need to add some way to ensure that only once instance is running (i.e. to not run if another instance takes more than a minute to finish). This is usually done via lock files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.