Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从 crontab 运行一个脚本,它有一个简单的服务器负载检查,如下所示:
server_load=$(bash -c '/bin/more /proc/loadavg | /usr/bin/cut -d" " -f1 | /usr/bin/cut -d"." -f1')
如果我从命令行运行脚本,我会得到服务器负载,如果我从 crontab 运行它,我会得到一个奇怪且无用的结果。
我确实寻找过有类似问题的帖子,但所建议的内容并没有帮助我解决我的问题。
整行可以简化为:
server_load=`cut -d. -f1 /proc/loadavg`
我怀疑这些问题与more想要一个终端并因此发出终端控制序列有关。
more