红联Linux门户
Linux帮助

如何在登录服务器时自动执行一段脚本?

发布时间:2015-10-05 15:16:28来源:linux网站作者:eroszhou

没有root权限时,将脚本放在 .bash_profile中(ubuntu 15.04)。例如:


# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export PATH

# Check Free Cores
clear
for node in 01 02 03 04 05 06
do
total=`pbsnodes | grep -A 3 node$node | head -3 | tail -1 | awk '{print $3}'`
occ=`pbsnodes | grep -A 4 node$node | head -5 | tail -1 | grep -o "/" | wc -l `
echo -n "node$node: $(($total-$occ)) "
done
echo


Shell脚本面试问题大全:http://www.linuxdiyf.com/linux/12539.html

两台Linux服务器同步目录脚本:http://www.linuxdiyf.com/linux/12394.html