0

I want to redirect the output of a linux command to a log_file. I am first echoing a command to trigger some logs, I want those logs to be stored in a file?

#echo "m" > /proc/sysrq-trigger >>   log_file

using it without log_files gives following output:
#echo "m" > /proc/sysrq-trigger
[11474.069710] sysrq: SysRq : Show Memory

However with ">> log_file" m is stored in log_file.

I am expectig the output of the command "sysrq: SysRq : Show Memory" to be stored log_file

I have tried the pipe method as well but no success.

  • 1
    Please [format your code properly](https://stackoverflow.com/help/formatting)< right now I don't understand it. BTW, `echo m >sudo ....` should create a file named `sudo` in your working directory. – user1934428 Jun 01 '23 at 12:56
  • 1
    Use pipe `|` to connect output of echo to input of another command – stark Jun 01 '23 at 13:45
  • `echo "m" > sudo tee -a /proc/sysrq-trigger` is `echo "m" tee -a /proc/sysrq-trigger > sudo` - it writes to a file named `sudo`. – KamilCuk Jun 01 '23 at 16:15
  • no, sudo is for super user access on linux as this command needs admin priviledges. This command is working fine without log file redirect. – user22000441 Jun 02 '23 at 05:40

0 Answers0