[SOLVED] Best folder to put scripts to be run by cron as various users
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
but how do I see what paths are current in my PATH now for cron? I'd still put the whole path in for the scripts into the crontab, but just curious since that would save me some typing if /usr/local was already in there, then I could put them in bin or create scripts to put them in, and I think I could omit the full path (if I wanted to in theory)
As for the scripts location, I just put them in a specially designated folder ~/personal/scripts. If multiple users need it, I use /usr/local/bin.
I have also used /opt/scripts in the past. But I do not know if there are reasons to not to do this.
As the post that suggested this indicated, that command must be run from WITHIN your cron. Running it on the command line does nothing but echo your current PATH, which is completely different than cron's PATH.
When done correctly, you should get something like:
cron path = /usr/bin:/bin
That's what it looks like on my system. This is why the location of nearly every command in your script must be hard coded, because only those commands that are located in /usr/bin or /bin will be found by cron.
Last edited by suicidaleggroll; 03-13-2013 at 12:36 PM.
if the script resides in the above PATH you can just execute it:
* * * * * foo.sh
but ONLY if you put the path in the crontab.
for me if it is a universal script (something that anyone on the system should be able to run, then Ill just place the script in /usr/bin and set visudo permissions for that specific script. the user can just execute foo.sh or what ever its called without the full path.
If its definitely personal scripts, then keep them in the user's dirs.
If its a generic script that affects others, then probably /usr/local/bin or /opt/scripts.
If a cron job for a group/project, use the projects bin dir if it has one.