日志清理
while true
do
cat ./file_name | while read line || [ -n "$line" ]
do
procnum=`ps -ef|grep $line |grep -v grep|wc -l`
if [ $procnum -eq 0 ]
then
sh sh start.sh $line
echo `date +%Y-%m-%d` `date +%H:%M:%S` $line "restart 服务" >>$basepath/shell.log
sleep 120
fi
sleep 1
done
done
iTerm2 提醒设置
https://www.jianshu.com/p/147e6625678d
# push 脚本
#!/bin/bash
set -x
cd 目录
git pull
git add .
git commit -m "更新配置"
chmod 777 目录/git.sh
pwd
git branch --set-upstream-to=origin/master master
echo "开始push"
pwd
git push --set-upstream origin master
pwd
前端启动命令
pm2 --name=“front” start npm – run dev
杀服务
ps -ef |grep {变量} | grep -v grep | awk ‘{print $2}’ | sed -e ‘s/^/kill -9 /g’ | sh
爬虫
#!usr/bin/python
import sys
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import redis # 导入redis 模块
path = '/usr/local/bin/chromedriver'
r = redis.Redis(host=' ', port=6379, decode_responses=True)
def run(username, password, url_type):
"""
获取 cookie 或者 token,并设置到 redis 中
key格式为:
:param username:
:param password:
:return:
"""
# # 无界面浏览器
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
# browser = webdriver.Firefox()
browser = webdriver.Chrome(chrome_options=chrome_options,executable_path=path)
# 有界面
# browser = webdriver.Chrome(executable_path=path)
url = ''
mq_url = " "
o_url = " "
if url_type == "o ":
url = o_url
elif url_type == "d ":
url = mq_url
else:
url = mq_url
browser.get(url)
time.sleep(2)
browser.find_element_by_id("username").send_keys(username)
browser.find_element_by_id("password").send_keys(password)
browser.find_element_by_id("submit").click()
time.sleep(3)
cookie_items = browser.get_cookies()
cookie_str = ""
# 组装cookie字符串
for item_cookie in cookie_items:
item_str = item_cookie["name"] + "=" + item_cookie["value"] + "; "
if item_cookie["name"] == 'token':
token = '"' + item_cookie["value"] + '"'
r.set(username + '_' + url_type + '_token', token)
print(username + '_' + url_type + '_token: ' + token)
cookie_str += item_str
cookie_str = '"' + cookie_str + '"'
print(username + '_' + url_type + '_cookie: ' + cookie_str)
r.set(username + '_' + url_type + "_cookie", cookie_str)
browser.quit()
if len(cookie_items) < 3:
print("执行失败")
r.set(username + '_' + url_type + '_token', 'false')
r.set(username + '_' + url_type + "_cookie", 'false')
return False
else:
print("执行成功")
return True
if __name__ == '__main__':
"""
需要安装
1、pip install redis
2、pip install selenuim
3、安装 Chromedriver 参考:https://www.cnblogs.com/jasmine0112/p/12745493.html
"""
print("开始获取 cookie and token 并设置到 redis 中")
argvs = sys.argv
print(argvs)
if len(argvs) == 1:
print("本地执行")
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
run(" ", " ", "d")
run(" ", " ", "o")
elif len(argvs) != 4:
print("请输入正确的执行方式")
print("执行方式: python3 getcookie.py username password oe/ddmq")
else:
username = argvs[1]
passport = argvs[2]
url_type = argvs[3]
run(username, passport, url_type)
IDEA
https://download.jetbrains.com/idea/ideaIU-2017.2.7.dmg
2019-12-05 14:37
https://blog.youkuaiyun.com/m0_37540696/article/details/102939088 License server 方式