CentOS time is incorrect by few seconds or minutes

If your centos server’s time is off by just few seconds, or 1 and half minute like mine, you are probably missing NTP deamon which would synchronize time with remote server.
Login as root ( or prepend sudo in front of following commands

yum install ntp ntpdate ntp-doc
chkconfig ntpd on
ntpdate pool.ntp.org
systemctl enable ntpd
systemctl start ntpd

And that’s it, you should see a message telling you how much off your time was. And if you do a date command now, it should show the exact same date as your computer.

root@server: ~# ntpdate pool.ntp.org
17 Oct 10:06:43 ntpdate[5211]: step time server 37.59.27.22 offset -32.044835 sec

Change Last Modified and Creation Dates on Linux or Mac OS X

Use terminal or console to get to the files you want to modify.
Then use touch command like this

touch -a -m -t YYYYMMDDHHMMSS *.pdf

To update timestamp of all pdf files in folder. Real life example, if you want to change last modified and create date to 1st of September 15:16:17 ( hours minutes seconds respectively ) for file todo.txt

touch -a -m -t 20170901151617 todo.txt

Centos7 Plesk 17.0 mu14 error updating psa-mail-driver-common

If you get this error while running yum update

--> Finished Dependency Resolution
Error: Package: psa-mail-driver-common-17.0.17-cos7.build1700161124.17.x86_64 (@PLESK_17_0_17-dist)
           Requires: libopendkim.so.10()(64bit)
           Removing: libopendkim-2.10.3-7.el7.x86_64 (@epel)
               libopendkim.so.10()(64bit)
           Updated By: libopendkim-2.11.0-0.1.el7.x86_64 (epel)
              ~libopendkim.so.11()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Just run

$ plesk installer --select-release-current --reinstall-patch --upgrade-installed-components
$ yum update

And you are all set

LibClamAV Warning: *** The virus database is older than 7 days! ***

If you are getting this error message, you probably haven’t updated default config file yet.

~# nano /etc/freshclam.conf

You need to comment the Example line – this is the usual mistake people forget, it’s rarely mentioned in google discussions ..

# Comment or remove the line below.
Example

change to

# Comment or remove the line below.
# Example

Next uncomment these 2 lines

DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/freshclam.log

And run freshclam. That will update the database.

~# /usr/bin/freshclam
ClamAV update process started at Wed Jan 11 08:24:05 2017
main.cvd is up to date (version: 57, sigs: 4218790, f-level: 60, builder: amishhammer)
daily.cvd is up to date (version: 22872, sigs: 1320094, f-level: 63, builder: neo)
bytecode.cld is up to date (version: 285, sigs: 57, f-level: 63, builder: bbaker)

It’s best to set up cron job that runs this update for you, e.g.

15      1       *       *       *       /usr/bin/freshclam

rsync between servers – how to filter by file extension

If you need to rsync some files over network, this is the command

rsync -c -az -ersync -c -e 'ssh -p 2020' --stats --progress --whole-file jan@myserver.com:data/files/ ~/data/files/

Script will connect to myserver.com on port 2020 and copy files from my home directory to local home directory.
If you want to access folder outside of your home directory, just add a slash after .com:

Filter by file extension

~# rsync -c -az -ersync -c -e 'ssh -p 2020' --stats --progress --whole-file --include="*/" --include='*.gif' --exclude="*" jan@myserver.com:data/files/ ~/data/files/

This will copy gifs only.
Always remember to combine exclude and include together – if you omit exclude parameter, your –include won’t have any affect.

Fastest rsync to copy millions of files between servers

rsync -a -e 'ssh -p 2020' --stats --whole-file jan@myserver.com:data/files/. ~/data/files

It doesn’t compress the file, doesn’t look for checksum difference, basically it just looks if file exists on new server – if it doesn’t copy it. Uses very little cpu and it skips building of file list