linux 工作中常用的命令

#定时启动你的脚本

在命令行输入:
crontab -e

#会出现编辑器

在里面编辑你要启动的脚本命令,以Python为列

5 10 * * * /usr/bin/python 然后输入你脚本的绝对路径

这将会在每天早上10点 5 分运行这个脚本

以下是 crontab 文件的格式:

{minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script} 
 minute: 区间为 0 – 59 分
hour: 区间为0 – 23 时
day-of-month: 区间为0 – 31 日
month: 区间为1 – 12. 1 是1月. 12是12月. 月
Day-of-week: 区间为0 – 7. 周日可以是0或7.周

可以按照自己的需求来定义时间

#Python在后台运行脚本的命令:

nohup python -u flush.py > flush.log 2>&1 &

#查看脚本状态的命令:

ps -ef | grep python

管道福,grep 后可以过滤多个脚本,根据自己的需求来定义。一定要在Python后面再加个 | grep,主要起到过滤作用

查看文件大小的命令:

du -sh 文件名

实时查看日志的命令

tail -f 日志的名字

猜你喜欢

转载自blog.csdn.net/yang_bingo/article/details/82791201