How can I log to a specific file in linux using logger command?

后端 未结 7 1960
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 16:07

I will run the following script:

#!/bin/bash
./myprogram

#get exit code
exitvalue=$?

#log exit code value to /var/log/messages
logger -s \"exit code of my prog         


        
7条回答
  •  隐瞒了意图╮
    2021-02-07 16:46

    $ man logger
    

    Logger provides a shell command interface to the syslog(3) system log module.

    You'll need to change your syslog configuration if you want it to log things to other places. You could establish a certain facility that has an output file in your home directory, for example. You would need to be root to do that, though.

提交回复
热议问题