New answers tagged

1

The file modification time, could be formatted with date: $ date -d @"$(stat -c %Y file1)" +'%Y%m%d%H%M%S' Use %X for last access time and %Z for last change. However, the maximum resolution of %X, %Y and %Z is seconds. For nanoseconds resolution use the %x, %y and %z options: $ date -d "$(stat -c %y file1)" +'%Y%m%d%H%M%S.%N' 20151101020000.012345678 ...


2

With GNU tools: find file -prune -printf '%TY%Tm%Td%TH%TM%TS\n' Or date -r file +%Y%m%d%H%M%S.%N If your ksh is ksh93 and it has been built with the date builtin enabled: command /opt/ast/bin/date -m -f %Y%m%d%H%M%S.%N file (command /opt/ast/bin/date invokes the date builtin bound to /opt/ast/bin/date, if you add /opt/ast/bin at the front of $PATH, ...


1

You can use something like: /bin/date +%Y%m%d%H%M%S -d "$(/usr/bin/stat -c %x find.txt)"


0

You can create a script on your local server or any other Linux server within your command: ssh root@server "date -s '$(date)'" You can run it with cron every hour or every few minutes as you like. However, its looks like not the optimal thing to do. Is your embedded system has the internet access or network access to any other Linux server you have? ...


0

I hope it won't be a crime, to answer my own question. I've found partial solution at AskUbuntu - works for me, at least in the first case. touch -d "$(date -R -r filename) - 2 hours" filename And for modification of all files in subfolder, type: find DIRECTORY -print | while read filename; do # do whatever you want with the file touch -d "$(date ...


1

The script has a line along:date +%d -r "$file"which works fine under linux, but … … on FreeBSD/PC-BSD will fail because the date command parses its command lines with getopt() and options must strictly precede arguments. The format string +%d is an argument, and must follow the -r option; otherwise -r isn't recognized as an option, but ...


2

Looks like this -r usage only made it into the sources on 7 May 2015. Perhaps your version doesn't do this yet? Revision 282608 - (view) (download) (annotate) - [select for diffs] Modified Thu May 7 20:54:38 2015 UTC (12 months, 1 week ago) by delphij date(1): Make -r behave like GNU's version when the option can not be interpreted as a number, which ...


2

You can set the date with ssh root@embedded "date -s '$(date)'" (i.e. run date locally and give the output to date -s on the remote system.) Of course you need another ssh command to open the interactive session, so either use keys and ssh-agent or a master connection to login. Normally, I would have also recommended using NTP, but if the machine ...


1

Neither aptitude nor apt-get can show that information in package views, because it's not part of the information these programs handle. The information available is that contained in the package indices (which doesn't involve downloading individual packages); you can find these in /var/lib/apt/lists, and they include the following information for each ...


0

There are several other utilities that can be used to copy files without modifying their timestamps. rsync (especially, using the '-t' flag) and cpio (using the '-m' flag) can both be used in this case. Check out the manual pages for each to see what other options might be useful.


0

The command cp -P doesn't apply to your needs. You are using uppercase argument letter -P which is used to never follow symbolic links. What you want to use is lowercase to preserve timestamps: cp -p As described in the comment section of the question, using the correct gid and uid solved the problem: sudo mount -t cifs //mynas/folder /home/mnt/nas/ ...


3

See if perl is portable enough: perl -MTime::HiRes=time -MPOSIX=strftime -e ' $now = int(time() * 1000); printf "%s.%03d\n", strftime("%H:%M:%S", localtime(int($now/1000))), ($now % 1000); ' Time::HiRes and POSIX are both core Perl modules. If you just want the epoch timestamp with fractional seconds: $ perl -MTime::HiRes=time -le 'print time()' ...


6

This will give you how many miliseconds have passed since the beginning of the Unix epoch : date +%s%3N You have to reduce the seconds*1000 which have passed until 00:00 AM today. Or you can just convert everything into miliseconds from this formula : date +%H%M%S%3N Like : h=$(date +%H) m=$(date +%M) s=$(date +%S) ms=$(date +%3N) echo ...


0

Made some modifications, but didn't solve the "% in subject" issue #include <stdlib.h> #include <stdio.h> #include <time.h> #define DAY (time_t)86400 #define WEEK (time_t)604800 #define MONTH (time_t)2678400 #define YEAR (time_t)31556926 /*I use this line in .muttrc: * set index_format = '/home/marcus/.mutt/mfdate "%9[%d.%m.%y]" ...



Top 50 recent answers are included