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

后端 未结 7 1968
佛祖请我去吃肉
佛祖请我去吃肉 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 17:07

    I don't think you really need to (or want to) involve logger/syslog for this. Simply replace the last line of the script with:

    echo "Exit code of my program is $exitvalue" >> /some/file/that/you/can/write/to
    
    0 讨论(0)
提交回复
热议问题