WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL reports environment session uptime, not system uptime

Open segin opened this issue 10 years ago • 8 comments

  • A brief description

Function calls requesting system uptime return the uptime for the current environment session, and not the uptime for the system.

  • Expected results

System uptime

  • Actual results (with terminal output if applicable)

Uptime of current WSL environment session, for example from a newly-spawned WSL session: image

  • Your Windows build number

14379

  • Steps / commands required to reproduce the error:
  1. Open a WSL environment session using bash.exe or similar.
  2. Run /bin/uptime
  3. Wait a few minutes
  4. Run /bin/uptime
  5. Kill all Linux processes and end the current WSL session.
  6. Launch a new WSL session.
  7. Immediately run /bin/uptime
  • Required packages and commands to install

Nothing additional that isn't provided by running LxRun /install

If this is actually the intended behaviour, then feel free to close this IR, but please document it as the intended behaviour (as it is currently undocumented.)

segin avatar Jul 15 '16 02:07 segin

Out of curiosity, is there something that is broken due to this behavior?

benhillis avatar Jul 19 '16 15:07 benhillis

From the subsystem's perspective we do not "boot" until you launch bash.exe for the first time. Marking this as "by design." If you have a scenario that is broken because of this please let us know.

benhillis avatar Jul 25 '16 15:07 benhillis

No broken scenario (yet), but I'm glad to see this clarified as a design decision.

On 25 Jul 2016 10:26 am, "Ben Hillis" [email protected] wrote:

From the subsystem's perspective we do not "boot" until you launch bash.exe for the first time. Marking this as "by design." If you have a scenario that is broken because of this please let us know.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BashOnWindows/issues/657#issuecomment-234987317, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdVxX-ygrSDdQuOh13GYZ4v9M5_KbWNks5qZNWngaJpZM4JNBuX .

segin avatar Jul 25 '16 21:07 segin

Closing this out.

benhillis avatar Nov 02 '16 15:11 benhillis

I realized you closed this out, but this is an issue for me. I really want to use WSL, but am forced to go with cygwin because of this.

While I understand why it responds this way, it really is quite astonishing of a response. Is there no way we can expose the system uptime for this?

oninoshiko avatar Jul 23 '19 17:07 oninoshiko

Can you describe your scenario in more detail? You should be able to use interop (running .exes) to query Windows state.

benhillis avatar Jul 23 '19 17:07 benhillis

We have a handful of windows machines in a mostly linux/unix environment. We have a system that remotely sshs in and checks a number of things, one of which is uptime. Rewriting the system to have a special code-path for the windows machines adds additional complexity incurring both immediate and future costs.

Not to mention, it's straight-up unexpected behavior to not have uptime show the time the system has been up. I don't think anyone who's used any linux or unix based system would ever expect that.

oninoshiko avatar Jul 23 '19 18:07 oninoshiko

I'm not sure if this is the best place, please correct me if it is not.

Another use case I've found was having cron jobs execute during a particular time. If we have a WSL on the machine, it seems to be entirely halted making it impossible for cron to work. I'm running WSL version 2, on a CentOS 7 install.

iam8up avatar May 11 '21 13:05 iam8up