I want to read logs conveniently from my server. I'm trying to write a script that reads output of journalctl
from my server, applying the parameters I pass to the script to journalctl
call. I may want to apply various filters, so I want arguments to my script to translate to journalctl
's arguments. For example
bin/log --since '2 days ago'
would run
ssh host journalctl --since '2 days ago'
I tried this:
#/usr/bin/env bash
ssh host journalctl "$@"
But when I call
bin/log --since '2 days ago'
I just says:
Failed to parse timestamp: 2
Ok, we got an argument with spaces that seems to transform to multiple arguments when passed as part of a command over SSH. Then I tried something like this:
#/usr/bin/env bash
ssh host bash -c 'journalctl autotests "$@"'
You can guess that doesn't do what I need.
How the hell do I pass $@
over ssh?