ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've just created a simple bash script to copy a directory from a mounted Windows filesystem to a directory in my home directory in Red Hat 9.
I,ve then added a command to the bottom of ~/.bash_profile to automatically run the script after login.
It all works fine and I'm happy with it - basically I log in - then it takes about 10 seconds for the directory to copy over (its 200mb's roughy) - then finally the Red Hat desktop loads - sure enough my updated directory has been copied over and is on my Red Hat desktop - that's fine
However - is this the best file to run the script from? - is there a more typical file later in the start process that might be more useful to run this script from? - Is ~/.bash_profile the typical place you'd run start scripts from for an individual user?
I must stress it works fine - I'm just wondering whether there's a file later in the start up process where it would be better to run the script from.
that's a pretty poor place to run it - every console you open will er do this action.... i'd suggest putting it (with an "&" at the end so it forks iinto the background!) in /etc/rc.local or a similar one off script....
but this action sounds extremely pointless.... why not just create a symlink to the windows directory to wherever you want it.... you sem to have come up with a very bizarre solution to a trivial problem...
Why not just create a cron job even, to run the script at a particular day/time (like when your most likely not using the system so you don't see a lapse of performance decrease)...
But other than that, I wouldn't run a script like that every time I login.. that would get annoying to me.
Acid - it was never a "problem" - I've already got a symlink on the Red Hat desktop to a directory above it ie "windows" - it was a trial learning exercise - nothing more - one question though - would it be the case that in opening a bash shell, the bashrc file checks back to the bash profile file causing the script to run every time I open a bash shell?
Yes, unless i'm very much mistaken. I know that sometimes some user specific scripts aren't sourced, but i'd be quite sure the that one is used every time.
No, I think that the file .bash_profile is loaded only on login, and .bashrc does not exec it every time you open a shell.
But I too think that this is a very bad place to place the shell. You can try to use cron, or may be can place a sym link for the process. But , it is your system and ultimately the decision is yours.
Every time you open a shell, .bashrc will run. I discovered this recently after putting the command to mount a samba share in this file. I started to notice that when I typed "mount" if would should the Samba shares being mounted multiple times. That has been taken out, and I am wondering if I can use if...fi to test if something is already mounted on a particular folder, and only mount the share if nothing is already mounted.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.