Pregunta

I dont know why everytime that I tried to make the .bashrc run a command affects my SFTP connection from other softwares... This time Im just trying to start my apache server automatically because the servers restarts every day at midnight so, Its kinda annoying to go to the command line and restart my apache server.. big fail but I guess, I cant do much about my school policies or whatever they do with their servers.. What I was simply adding at the end of this file .bashrc it was this

~/apache/bin/apachectl start

but this simple command creates immediately conflict with my connection SFTP using other softwares.. So, Im not sure which is the proper way to do this..

¿Fue útil?

Solución

You really really do not want to put this in your .bashrc. The bashrc gets executed for EVERY shell you start. You could potentially be running this command hundreds of times per login session.

Read the bash man page and figure out which of the various start up files you want this in, my guess would be the .bash_profile script. Even then it seems very odd to me...

http://www.linuxfromscratch.org/blfs/view/6.3/postlfs/profile.html

However, to avoid the sftp problem you need to make sure that your .bashrc script does not write anything to STDOUT. If you run a commmand inside it redirect the output to /dev/null or a logfile. In general it's a very bad idea to run any commands in the .bashrc, you should mostly be setting configuration variables.

Running commands in .bash_profile is sort of ok, but in the long run it almost always causes more problems that it solves.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top