Questions tagged [time]

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

Filter by
Sorted by
Tagged with
5 votes
4 answers
673 views

How can I make time measurement DRY in my bash scripts?

Based on this answer, to measure the time in my bash scripts I can use: start_time="$(date -u +%s.%N)" sleep 5 end_time="$(date -u +%s.%N)" elapsed="$(bc <<<"$...
0 votes
3 answers
61 views

Read and convert date from file

I'm using a CentOS and I want to write a shell script. So I have a file with a date: > > cat VM1_EOMAP_TIME.log 07 Sep 2022 16:30 > And I want to get the minutes since current time and the ...
3 votes
1 answer
208 views

Is the kilobyte used by time and ulimit commands either 1000 (SI) or 1024 (old school) bytes?

From man time: M Maximum resident set size of the process during its lifetime, in Kilobytes. From ulimit -a: max memory size (kbytes, -m) unlimited But a "kilobyte" may mean ...
  • 165
0 votes
0 answers
23 views

linuxptp PHC with delay > 10us

I am using linuxptp package to sync between my 2 linux machines both have same configuration Linux 5.10.0-14-rt-amd64 #1 SMP PREEMPT_RT Debian 5.10.113-1 (2022-04-29) x86_64 GNU/Linux. I am getting a ...
5 votes
0 answers
127 views

tee is faster than no tee

I have this simple bash script #!/bin/sh for i in {1..1000000} do echo "hello ${i}" done That prints a message a million times I try to compare the performance of dumping all the ...
  • 151
1 vote
0 answers
78 views

Multiple Scripts all in one with breaks [closed]

I’m writing a script where instead of using ‘sleep 600’ (for example), i actually want to execute another script for the same amount of time as sleep. So basically, instead of “doing nothing” for 10 ...
19 votes
3 answers
2k 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?
  • 2,046
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:...
0 votes
1 answer
116 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 ...
2 votes
1 answer
256 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 ...
0 votes
2 answers
140 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 ...
  • 3
-1 votes
1 answer
277 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....
  • 352
0 votes
1 answer
72 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. ...
2 votes
2 answers
39 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 ...
1 vote
1 answer
799 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+...
  • 38.9k
3 votes
1 answer
358 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 ...
  • 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 ...
1 vote
1 answer
189 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 ...
  • 101
0 votes
2 answers
59 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 ...
  • 1,325
2 votes
1 answer
705 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 ...
0 votes
1 answer
153 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 ...
  • 2,333
0 votes
2 answers
319 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 ...
  • 101
0 votes
1 answer
82 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 ...
0 votes
0 answers
62 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, ...
0 votes
0 answers
101 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: ...
  • 1
0 votes
1 answer
315 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 ...
0 votes
0 answers
56 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 ...
  • 1
1 vote
0 answers
94 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 ...
  • 111
0 votes
1 answer
516 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 ...
  • 141
1 vote
3 answers
296 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. ...
0 votes
0 answers
26 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 ...
0 votes
1 answer
60 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 ...
  • 21
0 votes
1 answer
73 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 ...
0 votes
1 answer
133 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 ...
  • 4,512
0 votes
1 answer
130 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 ...
0 votes
1 answer
144 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. ...
  • 105
4 votes
4 answers
704 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 ...
  • 143
11 votes
2 answers
891 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 ...
0 votes
1 answer
223 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 ...
  • 125
1 vote
0 answers
27 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 ...
  • 251
0 votes
2 answers
205 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?
4 votes
3 answers
304 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 $ ...
-1 votes
3 answers
163 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 ...
0 votes
3 answers
1k 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 ...
0 votes
0 answers
14 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.
0 votes
1 answer
85 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. ...
's user avatar
2 votes
1 answer
441 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 ...
4 votes
1 answer
206 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 ...
  • 213
2 votes
0 answers
44 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-...
  • 21
0 votes
0 answers
22 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 ...

1
2 3 4 5
10