
mkdir /tmp/mydirtouch /tmp/mydir/myfile
其实这样也不能算是同时执行,Linux的命令是顺序执行的,就算是shell脚本,里面写了一大堆命令,同样也顺序执行的。如果前一个命令执行的时间比较长,后面的命令就只有等待了。如果命令执行时间比较长,又想让命令同时执行,恐怕只能打开多个虚拟终端才行(右键虚拟终端界面,选择“打开标签”),打开多个登录的虚拟终端其实是运行了多个“会话”,多个“会话”中的命令才是“同时”执行。
只需要3步,已经验证成功:1、编写/root/addRoute.sh(内容是需要自动执行的命令)如下:
route add default gw 192.1.2.254
2、授权:chmod 777 /root/addRoute.sh
3、在/etc/rc.d/rc.local加入脚本执行命令,如下面最后一行(注意是全路径,如/bin/sh):
[root@jk ~]# cat /etc/rc.d/rc.local #!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuff.touch /var/lock/subsys/local
/bin/sh /root/addRoute.sh
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)