2022 Developer Survey is open! Take survey.

Questions tagged [timestamps]

timestamp is used for questions that are about data specifying seconds since the epoch (19700101T00:00:00) or possible some other standard, and also for (date) and time information in filenames.

Filter by
Sorted by
Tagged with
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?
user avatar
  • 1,974
1 vote
2 answers
79 views

How to delete files based on the creation date of other files?

I have a security camera running Linux (busybox 1.32.0) which I can set to record video continuously in (configurable) 30 seconds chunks in a folder structure: recording/2022/04/26/15/2022-04-26-15-30-...
user avatar
  • 204
0 votes
0 answers
32 views

Change file creation timestamp on an exFAT volume from Linux

The question As of today, Unix standards don't support a file "creation time" attribute. However, many filesystems, like ext4, exFAT and NTFS, internally do save a creation time for their ...
user avatar
  • 17.6k
0 votes
0 answers
46 views

How can I modify a file creation time in btrfs

I wanted to have snapshots on my filesystem. Since the btrfs-convert tool is not available anymore, I was forced to convert my filesystem by copying it file-by-file on a new file-system. However, I ...
user avatar
  • 234
0 votes
1 answer
142 views

Format datetime as UTC with strftime (for use in git)

I can format dates and time pretty flexibly with strftime, but from what I can see, this only will give times in my local timezone; I can add the timezone offset (e.g. '%Y %m %d-%H:%M:%S%z' for a ...
user avatar
0 votes
1 answer
32 views

Subset of File between two dates, when some dates are invalid

I have come across several similar questions, but the solutions seem to be failing me, and I believe it is because I have some junk data in my file that is breaking my attempt to filter by time stamp. ...
user avatar
  • 107
0 votes
1 answer
38 views

date string column to timestamp column in a log file

I have log.txt with sample output like these: ... 10-Feb-2022 15:15:14.099 lorem 10-Feb-2022 15:15:15.133 ipsum 10-Feb-2022 15:15:16.233 dolor ... I expect the output of filtered log.txt will be ... ...
user avatar
0 votes
1 answer
17 views

How can I convert logline timestamps to a different time zone?

I have some logs with a timestamp at the beginning of each line (YYYY-MM-DD hh:mm:ss). The timestamps are UTC time, but often I want to know when something happened in my local time. I can convert in ...
user avatar
  • 845
3 votes
1 answer
462 views

Change file creation date and time based off of file name

I was copying Asterisk call recordings from our main server to a samba share and the creation date and times were changed to the current date and time. The file format is: in-xxxxxxxxxx-xxxxxxxxxx-...
user avatar
0 votes
3 answers
49 views

How do I alter datestamps of files recursively but only if the existing file doesn't match a particular date?

I have a folder (many files and subfolders, a few hundred gigabytes). I duplicated the folder with rsync, but forgot to preserve the timestamps. The new folder has now had many new files added to it ...
user avatar
  • 101
0 votes
2 answers
51 views

One-way synchronize folders [duplicate]

Using Bash, I need to copy and override some files that have equal names but different contents from source, while ignoring equal files. I saw no option in cp's manual for copying only differing files....
user avatar
0 votes
1 answer
31 views

Global setting to have time stamp pre-pended to all lines outputted to terminal?

I'm working on a server where there are many different shell scripts used to trigger processes. These shell scripts use echo commands primarily to produce terminal output that is captured by an agent ...
user avatar
6 votes
1 answer
518 views

Different timestamps in SFTP "ls -l" vs. "ls -lh"

I have a 3rd-party SFTP server on which I want to check some file timestamps. However, I do get different results for the same file if I use ls -l vs. ls -lh: sftp> ls -l [...] -rwxrwxrwx 1 0 ...
user avatar
1 vote
1 answer
257 views

I need creation date and time of file in Linux [duplicate]

I need to creation date and time of file in linux. I have tried below two command but did not get any output. sudo debugfs -R 'stat <inode_no of file>' "mount point name". This gives ...
user avatar
1 vote
0 answers
30 views

mtime difference of microseconds

The following file $ stat Louis-Jens-Kusi.jpg File: Louis-Jens-Kusi.jpg Size: 183455 Blocks: 360 IO Block: 4096 regular file Device: 824h/2084d Inode: 4720932 Links: 1 ...
user avatar
  • 11
0 votes
2 answers
330 views

Why tldr | xclip outputs escape codes looking like timestamp, and how to remove it?

Problem I want to copy the output of tldr to clipboard, and then paste that to text editor. I execute: tldr pwd | xclip -sel clip When I paste from clipboard, I get: pwd [0mPrint name of current/...
user avatar
  • 359
1 vote
1 answer
115 views

curl only download if timestamp on server is newer

curl --help didn't help me much. I couldn't easily find if such an option exists. Apparently wget -N is as close as possible to what I want.
user avatar
0 votes
0 answers
45 views

How to place timestamps on data received via serial port?

Is there a way to get the timestamp at a driver level of when each byte comes from serial port? I want to connect an embedded device but I need to know an approximate time the data arrives, preferably ...
user avatar
-1 votes
1 answer
44 views

How can I calculate the mean time value of this file with column with absolute Times

I haved a file like this: 1633092723, TRANSFERCHECK: OK 1633092771, TRANSFERCHECK: OK 1633092777, TRANSFERCHECK: OK 1633092805, TRANSFERCHECK: OK 1633092811, TRANSFERCHECK: OK ...
user avatar
2 votes
3 answers
434 views

Backup and restore timestamps of files/directories?

We need to backup the a/c/mtime-stamps of files and directories, and have the ability to restore them if necessary. An example command to back up could be: $ timestamp backup --all-stamps --incl-dir-...
user avatar
0 votes
1 answer
591 views

How to ignore timestamp of the files while performing diff operation

I created a file named me.txt with text This is dummy text Then I made a TAR out of it and named me.txt.tar. Now after a minute I again created a file with exactly same name and the text (basically I ...
user avatar
0 votes
3 answers
151 views

How to make a link to have the same timestamp as the target file

Suppose you have file file with a given mtime. If I create a symlink sym pointing to file via ln -s the symlink itself gets a mtime-stamp that corresponds to the time where the symlink was created ...
user avatar
  • 16.7k
2 votes
1 answer
76 views

Generate timestamp between 2 values

Im trying to generate a timestamp series between 2 timestamp values with 30mins interval. Here is what I already prepared. start_ts='2021-08-07 15:00:00' end_ts='2021-08-11 05:00:00' while ! [[ $...
user avatar
0 votes
1 answer
83 views

Compare timestamp from two log files and report final time in minutes

I have 2 Files with file-path and timestamps. I'm trying to compare contents from file1: "192.168.1.4_time-final2" with file2: "192.168.1.1_file-stat" and after successful File-...
user avatar
  • 51
0 votes
1 answer
78 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
2 answers
49 views

how to use sed to replace a string of characters in quotes

I want to use sed to replace the current time in the code below time0=$(date '+%Y-%m-%d') time1=$(date '+%H:%M:%S') time=$(echo ""$time0"T"$time1"Z") replace $time on ...
user avatar
  • 11
3 votes
1 answer
1k views

How to get stamp in shell script in JSON file using jq tool?

I have question regarding shell scripting and jq tool to create a json file with timestamps. echo "{\"vtg\":[$value]}" | jq -a '. + {date: now|strflocaltime("%r")}' > ...
user avatar
  • 41
0 votes
1 answer
36 views

find -newerct filter on cp-copied files has different result compared to original files

I've migrated some 73k files from source/ to dest/ with cp -pR. Before I did that I checked with find source/ -type f -newerct $(date -d @1623247288 +"%Y-%m-%d") that I can grab new files. I ...
user avatar
0 votes
1 answer
97 views

How to correctly subtract time in AM and PM in shell script?

I am facing a situation where suppose I subtract 01:00:00 AM and 23:00:00 PM using my below script I am getting a difference of 21 hours when it is only 2 hours. Here's my script: #!/bin/sh Tm1=$(...
user avatar
  • 13
1 vote
0 answers
101 views

Timestamp lost when copying file to samba share from another Linux box

I've got a samba share on an Ubuntu 20.04 box. When I copy a file to the share from a Windows box the timestamp is maintained, but when I do the same thing from another Ubuntu 20.04 box, the timestamp ...
user avatar
  • 63
0 votes
2 answers
43 views

Compare the times of different files using shell script

I have a file with below contents. Here i need to compare the timestamp of HIW.ear in the first line with the timestamp of .jars from the second line and i am running out of ideas on how to do this. ...
user avatar
0 votes
2 answers
342 views

Compare content of two folders/disks (including timestamps,permissions)

I have two directories on two different hard drives and want to check if the content is really exactly the same. From what I read I can use diff -rq dir1 dir2 to check if files are missing or differ. ...
user avatar
0 votes
3 answers
127 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
1 vote
1 answer
94 views

Find files created during a certain hour of any day

I understand that it is possible to use find to locate files that were created during a specified range of time. For example, the following should output a list of all the files created (inode change ...
user avatar
  • 3,465
3 votes
0 answers
51 views

How to stop dolphin from updating file access times

I would like to utilize access times as an indicator to figure out which files I am actually still using. But whenever i view a directory in dolphin, the access timestamps of many of the contained ...
user avatar
0 votes
1 answer
167 views

Get UTC process start time in Linux

This ps command gives timezone-specific time: $ date Mon Mar 22 19:17:54 MSK 2021 $ ps -eo pid,cmd,lstart PID CMD STARTED 1 /init ...
user avatar
1 vote
1 answer
177 views

top TIME+ Is using a comma delimiter instead of the usual colon. Does this signify different units?

I have been running a process for quite a while, so long that the usual TIME+ format in top is not the usual MM:SS.milliseconds. Instead my process time is reported like this PID USER PR NI ...
user avatar
1 vote
2 answers
307 views

Log Files - A command to search for gaps of over 2 minutes in logs

Wondering if someone can help with a query I have re: log files? I am looking to run a command that will search through a log file and look for sections of that log file where there are no updates for ...
user avatar
  • 11
4 votes
2 answers
773 views

Why rsync on Linux does not preserve all timestamps (creation time)?

I am using the current rsync 3.2.3 version and when I run stat command it shows me this info for my file. stat '/test.txt' File: /test.txt Size: 0 Blocks: 0 IO Block: 4096 regular empty file ...
user avatar
-1 votes
1 answer
137 views

change last modification date for many files using references

I have performed a backup and on restoring it, unfortunately, all file access times were set to the timestamp of the DateTime of this restoring process. How now to set all timestamps from the backup (...
user avatar
  • 13
2 votes
0 answers
348 views

sftp - timestamp | ls -l vs ls -l <file>

we have the following phenomenon sftp connectionn and then sftp> ls -l rw-r--r-- 1 530 530 36 Feb 11 08:21 test.txt sftp> ls -l test.txt -rw-r--r-- 0 530 530 ...
user avatar
  • 21
1 vote
0 answers
154 views

How can I display nanoseconds with stat command on Unix?

I am using FreeBSD but it does not show nanoseconds for the file with stat command. The file system is ZFS. stat -f "Access (atime): %Sa%nModify (mtime): %Sm%nChange (ctime): %Sc%nBirth (btime): ...
user avatar
1 vote
1 answer
745 views

rsync keep access time (atime), how?

I am using rsync-3.2.3 on Fedora 33 (GNOME). But how can I keep the access time (atime) for my files and folders? I can only keep the modified time (mtime) with this command: rsync -t
user avatar
-2 votes
1 answer
43 views

Why doesn't the bash commands history save datetimes by default in Linux/Debian? [closed]

The bash history does not display or even just save the datetimes of when commands where run. This severely limits the usefulness of the bash history and I can't see any good rationale for it. One can ...
user avatar
  • 3,430
1 vote
1 answer
221 views

Birth time after Modify time in stat command

I have a folder with a Birth time later than its Modify time: File: Pictures Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 804h/2052d Inode: 31724953 Links: 4 Access: ...
user avatar
  • 377
1 vote
1 answer
209 views

Since when do Unix systems support birth/creation time (btime/crtime) for files and directories?

Does anyone know when Unix supports birth/creation time stamps for files and directories? If possible also when first file manager (GUI) displays it by default for users. For comparison with Windows, ...
user avatar
2 votes
2 answers
2k views

Convert/replace time from epoch milliseconds to human readable date in logfiles

I have a log file with the following structure Example: 1522693524403 entity1,sometext 1522693541466 entity2,sometext 1522693547273 entity1,sometext ... Now I would like to replace the time from ...
user avatar
0 votes
2 answers
555 views

Gzip of folder while retaining original timestamp

I want to do gzip of folder, and also want to retain original timestamp for that folder. Can someone suggest any way around it. i tried below mentioned code. The timestamp which i am getting the time ...
user avatar
0 votes
0 answers
43 views

My harware clock is OK, but the system clock is not, and I cannot set it [duplicate]

From Linux, the date --iso-8601=s command returns: 2020-10-23T22:26:22+01:00 The timezone is correct, the UTC offset is correct (England, daylight saving time). However the clock is one hour ahead. ...
user avatar
  • 449
6 votes
2 answers
898 views

sort directories by last modified content (recursive)

I have a bunch of directories at the same level and would like to sort them according to the last modified date of the content (recursive) inside them. However, in nautilus, it looks like the ...
user avatar
  • 241

1
2 3 4 5
11