Command to know last reboot time in SLES - linux

I have been trying to get the last system reboot time with seconds in SLES 12 version with below commands but none of them giving the time with seconds.
who -b
system boot 2020-07-30 23:02
last reboot
reboot system boot 4.12.14-95.54-de Thu Jul 30 23:02 - 11:41 (3+12:39)
As uptime -s doesn't work in SLES, is there any command to get the last system reboot time with seconds.

Use the option -F / --fulltimes of last to display the times including seconds.
last -F reboot

Related

Time not set right, date -u and hwclock -u yield different results

so i am having this weird problem with my clock on pc. I am currently using Kali Linux 2018.1.
Basically my problem is that my computer time is one hour behind every time i start my pc. So is my hardware clock. What i find even weirder is that date -u and hwclock -u display different results:
root#horse:/etc# date
Sat Mar 3 22:50:56 CET 2018
root#horse:/etc# hwclock
2018-03-03 22:50:59.654599+0100
root#horse:/etc# date -u
Sat Mar 3 21:51:03 UTC 2018
root#horse:/etc# hwclock -u
2018-03-03 23:51:09.904595+0100
root#horse:/etc#
The time from hwclock -u is the correct one.
Can you please help me understand and solve this issue?
Since hwclock -u showed the correct time:
#hwclock -u > date -s
#hwclock -w
This seemed to do the trick.
Alternatively :
#date -s M/D/Y +hh:mm
#hwclock -w

Debian init.d script fails to sleep

This problem occurs on a Pogoplug E02 running Debian jessie.
At startup the network interface takes several seconds to come online. A short delay is required after the "networking" script completes to ensure that ensuing network operations occur properly.
I wrote the following script and inserted it using update-rc.d. The script inserted correctly and executes at boot time in proper sequence, after networking and before the network-dependent scripts which were modified to depend on netdelay
cat /etc/init.d/netdelay
#! /bin/sh
### BEGIN INIT INFO
# Provides: netdelay
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Delay 5s after eth0 up for Pogoplug
# Description:
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
./lib/init/vars.sh
./lib/lsb/init-functions
log_action_msg "Pausing for eth0 to come online"
/bin/sleep 5
log_action_msg "Continuing"
exit 0
When the script executes at startup there is no delay. I've used both sleep and /bin/sleep in the script but neither effect the desired delay. Boot log showing this attached below.
Thu Jan 1 00:00:25 1970: Configuring network interfaces...done.
Thu Jan 1 00:00:25 1970: INIT: Entering runlevel: 2
Thu Jan 1 00:00:25 1970: Using makefile-style concurrent boot in runlevel 2.
Thu Jan 1 00:00:26 1970: Starting SASL Authentication Daemon: saslauthd.
Thu Jan 1 00:00:29 1970: Pausing for eth0 to come online.
Thu Jan 1 00:00:30 1970: Continuing.
Thu Jan 1 00:00:33 1970: ntpdate updating system time.
Wed Feb 1 05:33:40 2017: Starting enhanced syslogd: rsyslogd.
(The Pogoplug has no hardware clock and has no idea what time it is until ntpdate has run.)
Can someone see where the problem might be?

How To to find out the creation time of the filesystem in linux

I want to know the creation time for the filesystem in linux .
You can use tune2fs tool to get creation time:
sudo tune2fs -l /dev/sda1
In result one of the lines is:
Filesystem created: Mon Apr 4 15:07:44 2016
Last mount time: Mon Dec 12 14:48:51 2016
Last write time: Mon Dec 12 14:48:50 2016
This command works on ext2 -ext 4 filesystem. The command is not supported on XFS filesystem. Refer the below link :man tune2fs

last command in linux shows `:0` in 3rd column, what does it mean?

I want to write a shell script sort out the data that last command shows.
I got this in my server.
root pts/0 10.168.136.175 Wed Sep 14 14:24 - 14:54 (00:29)
root :0 Mon Sep 12 10:34 - 11:00 (00:25)
reboot system boot 2.6.18-308.el5PA Sun Sep 11 11:31 (86+03:05)
I did some search, there are some saying :0.0 in the 3rd column means login locally, second column means what kind of terminal been use, like pts and tty.
But what does the :0 in line 2 second column in my log?
I am using redhat 6.5.
It means local computer. Generally each session represented by pairs ip_address:display_number. When you logged in locally the IP address is omitted. That's why there is nothing before :. Display number is actually the session number from the specified IP address. So, 0 means the first session

Getting CPU utilization information

How could I get the CPU utilization with time info of a process in linux? Basically I want to let my application run overnight. At the same time, I would like to monitor the CPU utilization during the period the application is run.
I tried top | grep appName >& log, it does not seem to return me anything in the log. Could someone help me with this?
Thanks.
vmstat and iostat can both give you periodic information of this nature; I would suggest either setting up the number of times manually, or putting a single poll into a cron job, and then redirecting the output to a file:
vmstat 20 4230 >> cpu_log_file
This would give you a snapshot of usage every 20 seconds for 24 hours.
install sysstat package and run sar
nohup sar -o output.file 12 8 >/dev/null 2>&1 &
use the top or watch command
PID COMMAND %CPU TIME #TH #WQ #PORT #MREG RPRVT RSHRD RSIZE VPRVT VSIZE PGRP PPID STATE UID FAULTS COW MSGSENT MSGRECV SYSBSD SYSMACH CSW PAGEINS USER
10764 top 8.4 00:01.04 1/1 0 24 33 2000K 244K 2576K 17M 2378M 10764 10719 running 0 9908+ 54 564790+ 282365+ 3381+ 283412+ 838+ 27 root
10763 taskgated 0.0 00:00.00 2 0 25 27 432K 244K 1004K 27M 2387M 10763 1 sleeping 0 376 60 140 60 160 109 11 0 root
Write a program that invokes your process and then calls getrusage(2) and reports statistics for its children.
You can monitor the time used by your program with top while it is running.
Alternatively, you can launch your application with the time command, which will print the total amount of CPU time used by your program at the end of its execution. Just type time ./my_app instead of just ./my_app
For more info, man 1 time

Resources