Tag Info

New answers tagged

2

The correct and complete answer is: To modify access time only with the "touch" command, you must use "-a" parameter, otherwise the command will modify the modification time too. For example, to add 3 hours: touch -a -r test_file -d '+3 hour' test_file From man touch: Update the access and modification times of each FILE to the current time. -a ...


2

There is a tool called logrotate read the manual page man logrotate it is started by cron and probably already cleaning the log directory you can add your own configurataion files to /etc/logrotate.d


1

The reason your test fails is because the condition test uses a value of $? that is non-zero. The reason it's non-zero is because date is producing a non-zero exit status. If you temporarily stop discarding date's stderr with the > /dev/null 2>&1 you'll get to see the error message it's producing. That will help you identify the issue. date: ...


1

It looks to me that your systems clock is not functioning, probably because of the battery not, or no longer providing enough current to keep the clock going during restart. (If the clock chip where bad, you should get a different error, ntpd should notice). That is why you reboot in 1970 when the "Unix era" starts. When ntpd starts it hears from the rest ...


4

Use find -exec for recursive touch, with command line args for dirs to process. #!/bin/sh for i in "$@"; do find "$i" -type f -exec touch -r {} -d '+3 hour' {} \; done You can run it like this: ./script.sh /path/to/dir1 /path/to/dir2


8

Almost all programs use the TZ environment variable to determine the timezone, and fall back to the system setting if that variable is not set. TZ=Pacific/Yap date TZ=Pacific/Yap xclock Almost all operating systems (even Windows) use timezone information from the IANA database. Most timezones have a name of the form Continent/Town where Town is typically ...


10

You can use zdump: NAME zdump - timezone dumper SYNOPSIS zdump [ --version ] [ --help ] [ -v ] [ -c [loyear,]hiyear ] [ zonename ... ] DESCRIPTION Zdump prints the current time in each zonename named on the command line. Example: $ zdump ~$ zdump Iceland Iceland Sun Jun 14 09:40:30 2015 GMT $ zdump Japan Japan Sun Jun 14 ...


19

Timezones are listed in /usr/share/zoneinfo. If you wanted the current time in Singapore, for example, you could pass that to date: TZ=Asia/Singapore date Sun Jun 14 17:17:49 SGT 2015 To simplify this procedure, if you need to frequently establish the local time in different timezones, you could add a couple of functions to your shell rc file (eg, ...


0

Most browsers don't do anything special to set the time stamp on a downloaded file, so the file ends up being dated from the download. Download managers usually change the downloaded file's modification time to match the Last-Modified header sent by the server. With command line tools, use wget or curl -R to set the file's modification time to the time sent ...



Top 50 recent answers are included