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

journalctl --after-cursor="s=3057f92d5b3e4afdb5eb91c22e880074;i=1f646;
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:

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: