journalctl –after-cursor is not working well with shell script

I am trying to get the logs from journalctl after a specified time with the use of cursor option. Below is code in script file.

value=$( journalctl -n 0 --show-cursor | tail -1 | cut -f2- -d: | sed 's/ /"/;s/$/"/')
echo "$value"
sleep 20
echo "journalctl --after-cursor=$value"
journalctl --after-cursor=$value

The ouput of this script file is

"s=3057f92d5b3e4afdb5eb91c22e880074;i=1f646;b=0bc7e6e9f16f4847b2d50e0a0dd31023;m=a10d4c4d1;
t=5bba8ac2477ae;x=1cc1645fed6ffc79"
journalctl --after-cursor="s=3057f92d5b3e4afdb5eb91c22e880074;i=1f646;
b=0bc7e6e9f16f4847b2d50e0a0dd31023;m=a10d4c4d1;t=5bba8ac2477ae;x=1cc1645fed6ffc79"
Failed to seek to cursor: Invalid argument

As we can see above the journalctl --after-cursor results in "Failed to seek cursor error".

However if the same is executed in command line terminal, the --after-cursor gives the output.

Is there something needed to be done before calling journalctl with after-cursor option in shell script?



Read more here: https://stackoverflow.com/questions/66271755/journalctl-after-cursor-is-not-working-well-with-shell-script

Content Attribution

This content was originally published by Seeker at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: