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

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

    I you can use cat - witch echoes your output then >> [file] witch prints the output to [file] inset of terminal so the command would be

    cat - >> [file]
    

    the down side is you have to use ctrl+C or ctrl+Z to exit logger is better for online code

提交回复
热议问题