作者:金良([email protected]) csdn博客:http://blog.csdn.net/u012176591
有时候需要同时启动一组后台服务,如TFTP下载服务、SAMBA通讯服务和NFS文件共享服务,每次到这个时候都要重复输入启动程序的命令,比较繁琐,这个问题终于解决了。
我写了一个脚本文件,命名myStart.sh,后缀.sh表示内容为shell脚本,同类的还有.bash。内容如下:
#!/bin/sh /etc/init.d/openbsd-inetd restart /etc/init.d/smbd restart /etc/init.d/nfs-kernel-server restart netstat -an|more ~
下面的三行分别表示启动TFTP、SAMBA和NFS服务。
我加上最后一行是为了查看TFTP服务启动成功与否。
写好后保存,然后执行以下命令
# chmod a+x myStart.sh
然后就可以运行脚本了,命令如下
# myStart.sh
root@ubuntu:/home/now# ./myStart.sh * Restarting internet superserver inetd [ OK ] Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service smbd restart Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the stop(8) and then start(8) utilities, e.g. stop smbd ; start smbd. The restart(8) utility is also available. smbd stop/waiting smbd start/running, process 2909 * Stopping NFS kernel daemon [ OK ] * Unexporting directories for NFS kernel daemon... [ OK ] * Exporting directories for NFS kernel daemon... exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/nfsroot". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x [ OK ] * Starting NFS kernel daemon [ OK ] Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:41395 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:41172 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:38168 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:60923 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:42122 0.0.0.0:* LISTEN tcp 1 0 192.168.37.129:41993 91.189.89.144:80 CLOSE_WAIT tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 :::47351 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 :::49404 :::* LISTEN tcp6 0 0 :::2049 :::* LISTEN tcp6 0 0 :::53797 :::* LISTEN tcp6 0 0 :::41894 :::* LISTEN tcp6 0 0 :::39466 :::* LISTEN udp 0 0 0.0.0.0:40285 0.0.0.0:* udp 0 0 0.0.0.0:914 0.0.0.0:* udp 0 0 0.0.0.0:49595 0.0.0.0:* udp 0 0 127.0.0.1:988 0.0.0.0:* udp 0 0 0.0.0.0:50675 0.0.0.0:* udp 0 0 0.0.0.0:33268 0.0.0.0:* udp 0 0 0.0.0.0:2049 0.0.0.0:* udp 0 0 0.0.0.0:56333 0.0.0.0:* udp 0 0 127.0.0.1:53 0.0.0.0:* udp 0 0 0.0.0.0:68 0.0.0.0:* udp 0 0 0.0.0.0:69 0.0.0.0:* udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:69 0.0.0.0:*
表示69端口被打开,即开启了TFTP服务。
查看系统环境变量:
root@ubuntu:/home/now# echo $PATH .:/usr/lib/jvm/jdk1.6.0_35/bin:/usr/lib/jvm/jdk1.6.0_35/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/arm-2009q3/bin
root@ubuntu:/home/now# mv myStart.sh /usr/bin/