一、用shell同时启动多个python脚本_服务器
1、背景是
有三个脚本a.py, b.py, c.py
三个都是爬虫,里面都是while(true)方式运行的,不会主动运行结束。
每次启动他们,就需要:
python a.py > logs/a.log
python b.py > logs/b.log
python c.py > logs/c.log
2、上linux批处理:
有点麻烦,想搞个批处理:
#!/bin/sh
python a.py > logs/a.log
python b.py > logs/b.log
python c.py > logs/c.log
3、发现有问题
运行发现只有一个python进程,看日志发现只有a运行了,b和c都没跑起来。
估计因为shell是顺序执行的,a没执行完,所以不会去执行b和c,查了一下果然。
4、同时运行方案
不过shell也提供了一个同时运行多个命令的方式:&符号。
于是修改为:
#!/bin/sh
python a.py > logs/a.log & python b.py > logs/b.log & python c.py > logs/c.log
就可以同时运行三个脚本了。
5、再加工一下
再加工一下,启动前先停止所有py进程:
#!/bin/sh
ps -ef | grep python | cut -c 9-15| xargs kill -s 9
python a.py > logs/a.log & python b.py > logs/b.log & python c.py > logs/c.log
保存为restart.sh
可执行权限:chmod +x restart.sh
二、安装goldenDict及配置
安装命令:sudo apt install goldendict
本地源词典配置
1.本地源词典需要下载,下载网址:http://download.huzheng.org/zh_CN/
进去以后选择下载词典,比如说《牛津英汉双解美化版》
2.在GoldenDict软件中添加本地源
方法:Edit -> Dictionaries -> Sources -> Files,点击Add,选择刚才创建的本地源目录,勾选Recursive复选框,点击OK,完成本地源词典配置
网络资源配置:
网络源词典配置
网络源词典来自网络。GoldenDict软件通过添加网络源词典网址的方法获取网络源词典。
常见的网络源网址有:必应、有道、百度。
网址如下
必应:https://cn.bing.com/dict/search?q=%GDWORD%
有道:https://dict.youdao.com/search?q=%GDWORD%&ue=utf8
百度:https://fanyi.baidu.com/#en/zh/%25GDWORD%25
谷歌:https://www.google.com/dictionary?aq=f&langpair=en|en&q=%GDWORD%&hl=en
推荐必应网络源词典,界面好看且解释较全面。下面以配置必应网络源词典为例,介绍网络源词典配置的方法。
方法:Edit -> Dictionaries -> Sources -> Websites,点击Add,在新添的网址输入框输入相关信息,勾选Enabled复选框,点击OK,完成网络源词典配置。