常见问题处理方法

rm 删除时报错’Argument list too long’

1
2
#替换rm -rf  命令,改用xargs 即可
ls | xargs rm -rf

清理 /var/log/journal 下的内容

1
2
3
4
5
# 如何判断占用了多少空间
journalctl --disk-usage

# 清理目录数据的阈值为500M
journalctl --vacuum-size=500M

ulimit 值超出允许范围导致无法登陆操作系统

一般在/etc/security/limits.conf文件中设置各种限制值。

但是请注意,如果你在文件中设置,你可能设置的值超出范围,导致不可预知的后果,例如无法登陆操作系统。

下面这个对open files的限制就是一个例子,它不识别unlimited,是一个有限的值。
所以如果你在/etc/security/limits.conf中设置了

1
2
* soft    nofile  unlimited
* hard nofile unlimited

那就完蛋了,因为你接下来的进程将登陆不了系统了。
我们最好先使用ulimit命令验证一下你将要设置的值是否合法。

1
2
3
4
5
6
7
[root@root ~]# ulimit -n 1024000000
-bash: ulimit: open files: cannot modify limit: Operation not permitted
[root@root ~]# ulimit -n 9999999999
-bash: ulimit: open files: cannot modify limit: Operation not permitted
[root@root ~]# ulimit -n 9999999
-bash: ulimit: open files: cannot modify limit: Operation not permitted
[root@root ~]# ulimit -n 999999

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!