Linux is great
Linux can be customized

Welp, not so much. Simple things are not possible to do.

After 1H research I can't have timestamp near each line over SSH.

I'm not talking "history", i'm talking live.

basiclly I want to see timestamp on every single output line.

Basiclly this :


But running automaticly for each command ever.

To be fair, same problem exists in PowerShell on windows

And no, I don;'t want to switch to some random halfbaked teminal.

  • 6
    Did you try piping the output linewise through some xargs wizardry echoing time and line? Or maybe awk even has a feature to do this.
  • 1
    @nitwhiz Look at links I provided

    I don't want to pipe it. I want it beeing by default.

    Sure I can do that :

    bash |ts

    And it works !

    But I want it by default withfout adding a line of code.

    Or maybe there is a way to do it on sign in ?
    EDIT : Actually it doesn't work. It works only for "sucess" commands.
  • 3
    Compile your own ssh client?
    Or a script that pipes stuff to and fro and modifies it the way you want
  • 2
  • 0

    Why ? As fun as it seems, too much work :)
  • 2
    @IntrusionCM nah, it's about the output.

    something like cat backup.log | xargs -I % -n1 sh -c 'echo $(date) %' or bash | ts

    imo, proper rant. you want something specific, you don't get it - that's when you should write a rant..:D
  • 1

    Works for BASH lines, but not output.

    But thanks ! That's one step closer

    Example in a picture
  • 3
    @NoToJavaScript if you *REALLY* want this, modify the exectued shell via:

  • 1

    A bit overkill, but I think I'll try.

    Thank you
  • 2
    @nitwhiz okay. It took me a while to grok it, mostly because it's weird in more than one way.

    This is usually what you would achieve by using a logging system inside the application.

    Everything outside will not have an "ms" exact timestamp.

    If you want to log everything, you will have to send it to an syslog daemon.

    I'm not 100 % sure if this is what he truly desires, but it's possible I guess.

    You can use logger to redirect the output to eg rsyslog and use rsyslog to redirect it to a specific TTY.
  • 2
    Sounds like you need zsh for me
  • 1
    @IntrusionCM Hmm nop

    It's just a fucking display. Some too,s are not loging timestamps. Sometime I run a 30 mins script and I want to know where is it ?

    I just want to have a timestamp in front of each line. We have 4K screens now, we have pleanty of space even for SSH output.

    The idea of recompiling SSH client seems better and better lol
  • 1

    Never heard of it and google search doesn't point to it on first page. (Only derivative things "Oh my z" or stuf like that)

    So I'll pass
  • 5
    @NoToJavaScript yes.

    And what you describe is exactly what a logging system does. Enriching output with helpful information.

    When you run a command, it gets directly printed to a specific TTY. Usually the TTY you're connected to.

    That's what your program does.

    You can either capture the programs output and enrich it by sending it to a logging daemon...

    Or you'll have to change the output directly.

    You could eg use Paramiko / Python, and instead of simply outputting each output line add additional content.

    Or use a simple C exec wrapper...or bash script (logging might be far easier)

    Either "capture" it and process it, or "wrap" it.

    Bash or ZSH can start a program, but they cannot modify the output stream of an process.
  • 2
    @NoToJavaScript “Z shell” https://en.wikipedia.org/wiki/...

    My dayli driver. Nothing required to get started, just pick a theme from the “oh my zsh” (theming) community and you’re off to go!

    Then, feel free to extend your theme using plugins! Add the Spotify plugin to NEVER LEAVE THE TERMINAL TO CHECK THE SONG NAME EVER AGAIN!

    Sounds good? You’ll love it. Time stamps are just the beginning.
  • 0
    @IntrusionCM I’m still switching between both, because he clearly posted a pic with the time stamp before typing the command.

    But yes, any reasonable okay language can make a good std wrapper. Look, I’ll quickly make one in node...
  • 1
    @010001111 yes.

    Although - when you have rsyslog and spare time - you can really do insane stuff that you wouldn't want to do manually.

    Multiplexing of many streams, eg.

    And you have a fuckton of possibilities to output the stream...
  • 2
    Read about screen and read about this https://unix.stackexchange.com/ques...
  • 1
    "Simple", yet no other OS has it anyway.
  • 1

    This maybe but then with custom piping commands?

    Otherwise @FrodoSwaggins might now!
  • 1
    Does anyone not use zsh?
  • 1

    Do you want the time stamp at the beginning of each line, or each prompt?

    Each line requires some magic.
    Each prompt is trivial.

    Prompt: modify your prompt. Derp.
    Line: piping your ssh output into awk/sed should be enough.
  • 1
    I can write you a tool that does this. It’s very easy. Or you can use a tool that already does do this. Even easier

    Typically the TERMINAL will do this not guest software sending data to your session.

    If you’re getting timestamps in your output data from your session you’re technically not getting the real output back from the program. Not that this is automatically bad but you should consider that. The terminal on the other hand can affix metadata to the disambiguation of the data and make something that is both readable and meaningful and preserved the original output of the program.

    Otherwise, 40 lines of c code, hunt through standard in for a newline. Copy bytes to standard out. Print timestamp and decorators after encountering a new line. Terminal echo will still work, output still works but is not original.

    But what about escape codes? Cursor movement, clearing the screen. Wtf does it mean to have timestamps all over the damn place? Try running a vim session through that.

    You have a lot of options, please consider them carefully.
  • 1
    BTW: you ARE going to have to pipe your ssh output through a program. And yes that IS what you want. Modifying the ssh client is no different than doing that so it’s a goofy ass proposition to consider that. Write the 20-40 lines of c code that i suggested above and pipe the ssh client through that. This isn’t hard and you don’t need to make it hard.

    Don’t tell us what you want and then list all the perfectly reasonable solutions that totally do work that you aren’t willing to use because reasons.
  • 2
    @NoToJavaScript works for bash but not output because every child process gets its own private stdout file descriptor. They are not inherited. That’s why you need to pipe the receiving ssh client through ts
  • 1
    @nitwhiz do not modify the executed shell. Just put your pipes in the right place.
  • 0
    @SortOfTested I don’t use zsh. It’s the only shell I’ve used where you can make it noticeably lag with unfortunate configurations. I never had a problem with tcsh let alone bash.
  • 1
    As others mentioned TTY loop back is a good option because it merges multiple process standard outs.

    Ok I answered everything that I had a problem with in this thread we should be good.
  • 1
    @Root bingo, beat me to it.
  • 0
    Sounds like an XY problem
  • 0
    can't you just change the .bashrc or .profile to include the timestamp?
  • -1
    ⦁ Academic Jobs Europe is a free job board for Academic and Research jobs in Europe. Find all kind of jobs, find it jobs in europe, academic position in a quick and efficient way
    For more details
    visit our
  • 3
    OhMyZSH is literally made for things like this.
  • 0
    @Root Done for promt and pipe is workin with | ts. Would love it to be automaticlly aded to each command
  • 1
    Did you try piping it through some command?
    Because we recommended this only like 5 times even though you do not want this.
  • 2
    I guess even he doesn’t know what he wants...
  • 0
    @010001111 @nitwhiz

    Piping WORKS, I’ve already told that. Now I want it to be automagic.
    So basically when I to “ls” it executes “ls | ts”
    Output is perfectly what I want. But I don’t want to write | ts every time
  • 0
    @010001111 @nitwhiz

    Here is an example. If I can get THIS without adding | ts I will love my setup so much !
  • 2
    It kind of feels like what you're searching for isn't a terminal prompt modification as much as a logging trap.

Add Comment