现在的位置: 首页 > Linux > 系统配置 > Ubuntu > 正文

shell脚本编程之一个简单的一键快捷启动应用程序

2015年11月01日 Linux, Ubuntu ⁄ 共 1133字 ⁄ 字号 暂无评论

由于博主也是刚写的第一个shell脚本程序,没有技术含量,大家可以学习一下里面的思路,写这个小程序的主要目的还是学习一下shell基础,有可能有人会说这么启动程序还不如之间来个开机启动这些就可以了,但有时候不想一开机就启动这些进程,按需要启动,所有就有了下面的程序

需要一键打开其他的程序,加上即可

#!/bin/sh
# 定义一个打开进程的函数
start() {
start=$1
two=$2
#=========启动进程
result=`ps -ef | grep -w ${start} | grep -v grep | wc -l`
if [ $result -le 0 ];
then
open=`${start}`
elif [${two} !='' ];
then
open=`${two}`
else
open=''
fi
result=`ps -ef | grep -w ${start} | grep -v grep | wc -l`
if [ $result -le 0 ];
then
echo "\n \033[31m${start}服务启动不成功!\033[0m"
else
echo "\n \033[32m${start}服务启动成功\033[0m"
fi
echo "==========================${start}服务进程启动(${result})个========================"
put=`ps -ef|grep ${start}`
echo "$put \n"
}

con=`redis-server /etc/redis/redis.conf
redis-server /etc/redis/redis6379.conf
redis-server /etc/redis/redis6380.conf
redis-server /etc/redis/redis6381.conf
redis-server /etc/redis/redis6382.conf
redis-server /etc/redis/redis6383.conf`
start nginx
start redis-server ${con}
nohup start phpstorm `/home/song/下载/PhpStorm-141.2402/bin/phpstorm.sh` &
nohup start navicat `/home/song/soft/navicat111_premium_en/start_navicat`&
#workermen=`php /home/song/wwwroot/vendor/bin/workermand start`

cd /home/song/wwwroot/wepiao/vendor/bin/
gnome-terminal --tab "php workermand start"


201510311446276359456846

给我留言

您必须 [ 登录 ] 才能发表留言!

×