Write to custom log file from a Bash script

前端 未结 5 609
渐次进展
渐次进展 2021-02-03 18:47

In Linux, I know how to write a simply message to the /var/log/messages file, in a simple shell script I created:

#!/bin/bash
logger \"have fun!\"
<         


        
5条回答
  •  独厮守ぢ
    2021-02-03 19:05

    If you see the man page of logger:

    $ man logger
    

    LOGGER(1) BSD General Commands Manual LOGGER(1)

    NAME logger — a shell command interface to the syslog(3) system log module

    SYNOPSIS logger [-isd] [-f file] [-p pri] [-t tag] [-u socket] [message ...]

    DESCRIPTION Logger makes entries in the system log. It provides a shell command interface to the syslog(3) system log module.

    It Clearly says that it will log to system log. If you want to log to file, you can use ">>" to redirect to log file.

提交回复
热议问题