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'd prefer to not keep it in my /home/myusername directory. Is there a best practice of where to store your shell scripts for cronjobs? At the root level?

I'm running ubuntu server 12.04 right now.

share|improve this question
1  
Why don't you want to store it in your home directory? If they're for you personally, that's exactly where they should be -- probably in some well-named subdirectory. If they're for the system has a whole, perhaps they should be somewhere else. (The distinction may be vague if you're the only user.) –  Keith Thompson Jan 13 '13 at 23:48
1  
There is really no "answer" to this questions....just many many preferences. –  mdpc Jan 14 '13 at 1:27

1 Answer 1

up vote 1 down vote accepted

typically, i put mine in /usr/local/bin/ (for scripts to be run by more than one normal user) and /usr/local/sbin/ (for scripts which are to be run as root). That way you separate the task that the script does, from cron which just automates launching it.

You'll need root to store files there, though.

share|improve this answer
    
"You'll need root to store files there, though." -- Not if you set the permissions right. I usually make /usr/local and its subdirectories group-writable, and add myself to the group (say, install). (Of course you'll need root to set the permissions in the first place.) –  Keith Thompson Jan 13 '13 at 23:49
    
i'm the main user and have root privileges. i'd prefer to have no one else edit this so am leaning toward /usr/local. there's no standard /mycronjobs directory though that people usually create? –  tarabyte Jan 13 '13 at 23:53
    
if you want noone else to be able to edit it. make it owned by root and set 500 or 700 permissions on it. - you could even do root:<your group> @ 550 or 770. for similar effect with you being able to edit without going root. imho it's cleaner to just sudo before editing the script though and have it owned by root. –  Sirex Jan 13 '13 at 23:54
4  
@terabyte, the standard directory is usually ~/bin which is then added to the $PATH. You asked for best practice, well it is saving your personal scripts in your home directory. It is neater and it makes it much easier to upgrade later. –  terdon Jan 14 '13 at 0:13
    
if this is a personal script (noone else needs run it) terdon is correct. –  Sirex Jan 14 '13 at 0:15

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.