Get Social

Howto fix bug “rsync: Failed to exec ssh -p No such file or directory”

I installed VS Code for my PHP Programming tasks and found Sync-Rsync package in marketplace. But, option “sync-rsync.shell”: “ssh -p 1234” wasn’t work…

Visual Studio Code with Sync-Rsync: Failed to exec ssh -p No such file or directory

And console output:
rsync: Failed to exec ssh -p 1234: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.1]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(226) [sender=3.1.1]

I tryed many config parameters, but this didn’t help.
However, the solution was found.
For fast fix simple do folowing:

Check you rsync version:
user@example:~$ rsync --version
rsync version 3.1.1 protocol version 31

As I heard, on rsync versions > 2.6 you can specify “-e ssh -p 1234” or can run rsync without it, ssh will work anyway.

edit your ~/.ssh/config
nano ~/.ssh/config

and set your server ssh settings like there:
Host example.com
User user
Hostname example.com
Port 29171
... (any your settings, like IdentityFile and other)

use rsync simply (without -e ssh, host username, port number etc.):
rsync -avz --progress --delete /home/user/some-local-path/ example.com:/home/serveruser/some-remote-path/

Bash script in one line to check free space in Linux

This task arose after the client sites were moved from the old VPS to the new one. On the new virtual server, everything is fine with the processor and the RAM, but the disk space is very close. It turned out that Vesta CP, which by default creates 3 backups, just filled the disk to zero.

The client asked me that when the place becomes small – it immediately became known. So I decided to make a very simple script “in one line”, which tracks disk space and sends a notification to e-mail. Such a script can be completely inserted in the Cron scheduler.

Actually, here it is:

Linux disk space monitoring script


if [ "`df | grep "/dev/sda1" | awk '{print $5}' | sed 's/\%//'`" -ge 95 ]; then echo "Disk usage exceeded 95%" | mail -s "Warning! My Server" mail@example.com; fi

When the disk usage reaches 95%, this one-line script will start sending messages with warnings to the mail “mail@example.com”. For example, you can add this line to the cron to check every 45 minutes. Of course, you can set it for every minute, but then your mailbox will just be fill up with these messages.

You can also go ahead and do so that we have one more warning when you reach 99%:

if [ "`df | grep "/dev/sda1" | awk '{print $5}' | sed 's/\%//'`" -ge 99 ]; then echo "Disk usage exceeded 99%!" | mail -s "Panic!! My Server" mail@example.com; fi

The situation is more serious here, so you can put in the cron to check every 5 minutes

As a result, we get in crontab:

# server usage alert
*/45 * * * * if [ "`df | grep "/dev/sda1" | awk '{print $5}' | sed 's/\%//'`" -ge 95 ]; then echo "Disk usage exceeded 95%" | mail -s "Warning! My Server" mail@example.com; fi
*/5 * * * * if [ "`df | grep "/dev/sda1" | awk '{print $5}' | sed 's/\%//'`" -ge 99 ]; then echo "Disk usage exceeded 99%!" | mail -s "Panic!! My Server" mail@example.com; fi

Of course, you can go even further and make these scripts to one script in a separate file and with a nice syntax and indentations. But the above option just works and it’s enough for me.

P.S. Make sure that you have the correct disk (“/dev/sda1” or something else) in the output of the df command.

Why Sphinx does not work on Ubuntu / Debian?

If the sphinx service is started, but the search on the site does not produce anything (and an no error), the problem can be as follows:
systemctl status sphinxsearch
When checking the status of the service – pay attention to the line

...
... To enable sphinxsearch, edit /etc/default/sphinxsearch and set START=yes
...

In this case, just edit the file / etc / default / sphinxsearch and change the value of the parameter “START = no” to “START = yes”.
It’s all!

Pages:1234567...13