Questions tagged [time]

`time` is a command line utility for running another program and summarizing resource usage

Filter by
Sorted by
Tagged with
8 votes
3 answers
581 views

What's the POSIX-compliant way to get the epoch timestamp in a shell?

I just noticed, that POSIX date doesn't seem to have the %s or %N format items. So I can't use those. What's an alternative, yet POSIX-compliant way to get the epoch timestamp in my shell script?
user avatar
  • 1,914
1 vote
0 answers
22 views

Counter-intuitive date command [duplicate]

I've been using date in a script in order to add one year to a specific date the following way: date '+%Y-%m-%d %H:%M:%S' -d "$DATE + 1 year" In this example, DATE looks like 2022-05-11 14:...
user avatar
0 votes
1 answer
28 views

How to store inner output of a nested bash command (within parenthesis) into one file and outer output into another file?

Here's my command: (time ( \ time sleep 1; \ time sleep 2 \ ) 2>&1 | tee inner.txt ) 2>&1 | tee outer.txt cat inner.txt shows: real 0m1.003s user 0m0.001s sys 0m0.002s real ...
user avatar
2 votes
1 answer
189 views

How to pass optional arguments to `time` command [duplicate]

man time shows it has some options, like this, to write just the time output to a file instead of to stderr: -o FILE, --output=FILE So, I try to use it $ time -o out.txt ls -o: command not found ...
user avatar
0 votes
2 answers
36 views

Unix Time Format with decimals

According to my understanding, Unix time format is the no of seconds calculated from 1970 00:00:00. For ex, if our current time is 1970 00:01:00, then unix time will be 60 (60 seconds has elapsed from ...
user avatar
  • 3
-1 votes
1 answer
83 views

Why is `time` not working on basic Bash script?

echo -e '#!/bin/bash\nsleep 10' > time_test.sh && chmod +x time_test.sh && time time_test.sh time_test.sh: No such file or directory real 0m0.186s user 0m0.105s sys 0m0....
user avatar
  • 302
0 votes
1 answer
44 views

Bash time converter

I have a question, How can I convert time from 12h AM/PM format to 24h? For example, I have input from stdin, some text like this: The event starts at 03:25PM and is expected to end at 06:17PM. ...
user avatar
2 votes
2 answers
28 views

Show variable's value in output of time command in zsh

I want to measure runtime of my program for a series on input variables (I am using zsh): for i in {1..3} ; do time sleep $i ; done The output is sleep $i 0,00s user 0,00s system 0% cpu 1,003 total ...
user avatar
1 vote
1 answer
410 views

How to disable DST changes for a timezone?

My system timezone is Asia/Tehran, and it has DST changes adjusts in Summer (spring forward) and fall back in Winter; however I do need to disable these DST adjustments and keep timezone always in UTC+...
user avatar
  • 38.2k
3 votes
1 answer
268 views

Check status of 11-Minute Kernel mode using adjtimex

I have a Debian Buster system which has the Kernel compiled without the CONFIG_RTC_SYSTOHC since I DO NOT want the 11-minute kernel mode to be on. However, I wanted to check if this change actually ...
user avatar
  • 75
0 votes
0 answers
21 views

Syncing Debian ntpd with Windows time server [duplicate]

unfortunately my problem listed here was not solved. It would seem that the issue was not with the ntpdate at all: when bypassing the university network all together, time sync works correctly. The ...
user avatar
1 vote
1 answer
57 views

Convert string time to seconds

I'm receiving an uptime in this format: 167h58m10.586582048s I want to transform it to seconds and discard the fraction part. I know awk could do that if only the received string had the same ...
user avatar
0 votes
2 answers
37 views

Does the time command include the memory claimed by forked processes?

I want to benchmark some scripts with the time command. I am wondering if this command catches child processes' memory usage. command time -f '%M' python my_script.py If not, what are my options? Is ...
user avatar
  • 1,287
2 votes
1 answer
216 views

Automatic time synchronization: `ntpdate` works but `chrony` does not

I have a problem with time synchronization of my Linux server. Both this machine and the NTP server are located in a (smaller) university data center hence the local address. What is strange is that ...
user avatar
0 votes
1 answer
72 views

Show only dates bigger than the search pattern even if the search pattern does not exist in the (log) file

I want to search the syslog for dates bigger than a specific search pattern. For example I want to find every syslog entry where the date is bigger than JAN 6 16:24:00. I know I could use sed (sed -n ...
user avatar
  • 2,281
0 votes
2 answers
156 views

Wrong Local time Archlinux + Xfce4

My system local clock has been displayed incorrectly for several days. when i run timedatectl status output is something like this : ➜ timedatectl status Local time: Sat 2021-12-25 19:16:57 +0330 ...
user avatar
  • 101
0 votes
1 answer
41 views

Duration of host unreachable by ping

Suppose I am pinging an IP and the destination is reachable. I did some change in the network so for a few seconds the destination was unreachable. After few seconds it comes live again. Is there any ...
user avatar
0 votes
0 answers
23 views

How to measure CPU, MEM usage and more for a short lived process

I've got a program with some compiled sorting algorithms, and I'm trying to use top to monitor its cpu and ram usage. Normally this would be fine, given that the process runs for a few minutes, ...
user avatar
0 votes
0 answers
50 views

Extremely slow booting time in Linux Lite since yesterday (Over 5 minutes), what should I do?

Here are the details: systemd-analyze Startup finished in 6.345s (kernel) + 5min 17.341s (userspace) = 5min23.687s graphical.target reached after 5min 17.322s in userspace here's what I get with: ...
user avatar
  • 1
0 votes
1 answer
118 views

settimeofday function can't change time

In Ubuntu 20.04 LTS, I write a program using C to change the system time. During the execution of the program, it does output the modified time using commands date and hwclock. But when the program ...
user avatar
0 votes
0 answers
36 views

PHC2Sys and syscalls with intel NIC have insane high latency

I'm currently working on a device wich is set to give out multiple different timing Protocolls from one PTP-grandmaster. For this i have an RockPro64 SOC with an Intel i350 NIC. For the Project I ...
user avatar
  • 1
1 vote
0 answers
49 views

Where, besides ntp.conf, do NTP servers used by ntpd come from?

The only NTP servers I have defined in /etc/ntp.conf are as follows: pool 0.debian.pool.ntp.org iburst pool 1.debian.pool.ntp.org iburst pool 2.debian.pool.ntp.org iburst pool 3.debian.pool.ntp.org ...
user avatar
  • 111
0 votes
1 answer
197 views

Who sets date/time automatically from the hardware clock at boot?

When Linux is booting, the current time must be fetched from a RTC chip and then set to Linux system date/time. I can do this manually by running hwclock --hctosys. But where exactly does this happen ...
user avatar
  • 131
0 votes
0 answers
14 views

How to sanitize user input timezone (TZ)?

In my POSIX sh script, I receive a user input timezone (=TZ) with an option. However, I want to throw errors when the tz is not legit (not found in the system). For example, TZ='CETX' date '+%T' ...
user avatar
0 votes
2 answers
85 views

When date and timedatectl?

About reporting and settings for date and time exists available the date and timedatectl commands - it according with the most common results available through the web. Practically both do the same. ...
user avatar
0 votes
0 answers
18 views

PHP - get datetime when jpg file at URL has been accessed last time

I know the date-time is saved in the access log, but I think its not possible to read this file from php. What is the easiest way to find out the date and time when a specific file (jpg) has been last ...
user avatar
0 votes
1 answer
57 views

Fixing problem with %(%H)T giving 12 hour

I am passing a time interval (in seconds) in ts. ts=13 printf -v hours '%(%H)T' "$ts" printf '%s\n' "ts: $ts ; hours: $hours" This is the incorrect result. ts: 13 ; hours: 12 As ...
user avatar
  • 21
0 votes
1 answer
37 views

How to stop rsyslog output TIMESTAMP

this same question has already received a solution but it doesn't work I'm looking for exactly this, I apply it in my rsyslog but it doesn't work for me, I restart my rsyslog, and nothing, I restart ...
user avatar
0 votes
1 answer
68 views

CentOS 7 changes my pc time +4 hours when I boot my windows disk

On my home pc I have two disks, one disk has windows10 installed, the other disk has CentOS 7.9 installed. It is an Asrock motherboard and has a boot gui that lets me choose which disk to boot, and I ...
user avatar
  • 4,111
0 votes
1 answer
75 views

Get date when the process was started in epoch seconds

I need to get the date when a particular process was started by PID. For this purpose, I use: stat -c %y /proc/PID In the output, I get the date in the following format: 2021-07-04 11:00:20.352976946 ...
user avatar
0 votes
1 answer
74 views

embedded Linux: date of system after boot: which file (it's date exaclty) is responsible

Do have an embedded linux device.It has a r/o rootfs. It has no connection to ethernet to get a time from some server. I am used that such a device comes up with date: 1.1.1970. Here it is different. ...
user avatar
  • 105
4 votes
4 answers
599 views

Calculate the logon duration of a user in minutes from a file

I have a file on a Linux system that looks like the following: May 6 19:12:03 sys-login: user1 172.16.2.102 Login /data/netlogon 13473 May 6 19:15:26 sys-login: user2 172.16.2.107 Login /data/netlogon ...
user avatar
  • 143
11 votes
2 answers
865 views

Command 'time' works on its own but not in a pipeline

Consider the following: # time sleep 1 real 0m1.001s user 0m0.001s sys 0m0.000s # echo foo | time sleep 1 bash: time: command not found Um... wut? OK, so clearly Bash is searching for ...
user avatar
0 votes
1 answer
108 views

Copying a same file multiple times

I have an audio file, and I am running a script to decode that audio file. Now I want to measure the latency of the system. So, I am running a script with a time command. like $ time ./uber.sh In the ...
user avatar
  • 125
0 votes
0 answers
31 views

Whats the Source and Precision of the "Date"-Clock

I need to verify the precision of a PHC clock on my Linuxboard. Therefor I want/need a clock, wich is as precise as possible. My first guess was to simply use the timestamps i get using the Date ...
user avatar
  • 1
1 vote
0 answers
22 views

Application for tracking applications usage times

Does there exist a program which allows to automatically track "window focus" time in, for example, Gnome? For example, I would like to track how much time per day I spend using a certain ...
user avatar
  • 241
0 votes
0 answers
53 views

no way to set hardware time with localtime?

I want to set the hardware time as my system time. sudo hwclock --systohc To check the hardware time after executing sudo hwclock --systohc. sudo hwclock -v hwclock from util-linux 2.33.1 System Time:...
user avatar
  • 35
0 votes
2 answers
126 views

How to generate the last 1 hour in seconds in unixtime?

I'm wondering if there is a way of generating the unixtime seconds for the past hour. So 3600 timestamps. Is there a quick date command?
user avatar
3 votes
2 answers
206 views

command-line tool for converting/formatting time

Is there a command-line tool to convert/format time? (I mean time, not date!) Here is what I was expecting: $ timeconverter --format '%s' 1h 3600 $ timeconverter --format '%h:%m:%s' 3665s 1:01:05 $ ...
user avatar
0 votes
3 answers
126 views

How often is unix time divisible by 10,000,000 seconds at midnight?

I accidentally discovered that May 3 2021 was one of the landmarks of Unix time. Exactly at midnight (UTC) the number of time_t was divisible by 10,000,000: $ date --utc --date='@1620000000' Mon 3 ...
user avatar
0 votes
3 answers
563 views

What does the SECONDS variable actually do?

So, as the title suggest, I noticed this weird thing where sleep essentially increment the time you give it as argument. Example: #!/usr/bin/env bash set -x SECONDS="1" while true; do ...
user avatar
0 votes
0 answers
12 views

time --format e command fails to recognize format arg?

Can someone please show me how to use time -f "%e" correctly? I want just the real wall clock time in seconds.
user avatar
0 votes
1 answer
52 views

Bash-Script: stop/abord if is last Sunday in March or October?

How can I stop/abort a bash-script when: is last Sunday in March? OR is last Sunday in October? Both should be checked here and if so the bash script should be stopped/aborted. Thanks in advance. ...
user avatar
1 vote
0 answers
195 views

command 'top' and 'ps' take a long time to show result

Recently, I find when I run commands like top or ps -aux on a server, it is very slow to show the result (STDOUT). I have checked the usage of disk space, memory, and CPU, all of them are OK. After ...
user avatar
4 votes
2 answers
171 views

Why this 'useless use of cat' with `detex` is 10x faster than the alternative?

I'm counting words in LaTeX files and intuitively used the command: $ cat *tex | detex | wc -w I then immediately noticed he useless use of cat, and did the task again with: $ detex *tex | wc -w ...
user avatar
  • 173
2 votes
0 answers
35 views

Making the locale time format more compact

dmesg -T gives human readable time format, and I want to make it more compact, from this [Пт мар 12 09:18:54 2021] wlan0: associated to this [12.03.21 09:18:54] wlan0: associated I'm using ru_RU.UTF-...
user avatar
  • 21
0 votes
0 answers
19 views

RHEL ways to simulate or virtualize time

I am trying to get my machine to simulate or visualize time without changing system time so that I can run code under simulated/virtual time so that my timestamps are in the past and such. I know ...
user avatar
1 vote
1 answer
53 views

faketime ignoring chronyc sources

I'm trying to do a "chronyc sources" call but with faketime. When in a terminal, "chronyc source|cat" works fine, but when I do faketime 'last friday 5pm' chronyc sources|cat, it ...
user avatar
2 votes
1 answer
143 views

How to configure openntpd to only rarely connect to NTP servers and sync the clock (or only when a large clock drift was detected)?

Because the clocks of multiple of my Debian/KDE machines went off by many minutes for no apparent reason and common mainboards (or at least the one that I have) don't have accurate, reliable hardware ...
user avatar
  • 3,420
0 votes
1 answer
591 views

How to pipeline sleep? sleep pipeline doesn't work

I wanted to simulate execution time of certain scripts for which I found sleep NUMBER does exactly what I want. In my scenario I needed something like sleep 5 | command | sleep 5 ... But it behaved ...
user avatar
  • 152

1
2 3 4 5
10