linux中bash如何清空日志

这篇文章将为大家详细讲解有关linux中bash如何清空日志,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

#! /bin/bash
log_dir=/var/log
root_uid=0
if [ "$UID" -ne $root_uid ];then
echo "This account not permission to execute."
exit 1
fi
cd $log_dir
if [ $? -ne 0 ];then
echo "This path not exists."
exit 1
else
cat /dev/null > messages
echo "clear logs jobs finished."
fi

关于“linux中bash如何清空日志”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。