New answers tagged

0

Try this from Host-A: ssh -tt Host-A ssh -tt Host-B ssh -tt Host-C


0

Try this: Host A.* User custom_user IdentityFile path/key.pem ProxyJump bastion-host You do not need to forward agent if you use Proxy commands. Proxy command mean main ssh tunnel carry port forward to destination host and the connection is established between your host and destination host, but agent forwarding is when ssh connections are chained one ...


2

When you just want to get whatever comes between the "mailto: and the ", then this would do the trick: grep -oP '(?<="mailto:)[^"]+(?=")' It uses positive lookbehind and positive lookahead which is supported by the Perl regex syntax (-P flag). If you need additional validation of the address, you might want to look into ...


0

write for stop the servive by a moment. service ntpd stop for permanent stop: service ntpd disable Regards


0

USER $SOLR_USER That variable isn't defined, so presumably Docker is deciding to run with a user it thinks is interesting.


0

Centos 8 /etc/profile.d/ File extension: .sh e.g '/etc/profile.d/my-script.sh' File permissions: 0644 (-rw-r--r--) Updates after: Logout & login (scope: global) Alternatives /etc/environment Put lines like: export ENV_VAR=env_value Updates instantly (scope: global) ~/.bashrc, ~/.bash_profile Put lines like: export ENV_VAR=env_value Updates ...


0

With find, on both Linux and MacOS, you have the -delete option. It already implies -depth. And for verbose output, you can add -print. So it's just : find . -type d -empty -delete -print


-1

cat server-list.txt not more server-list.txt (more is paginated) If you're scripting this them it's probably easier to use a keyless password rather than going through sshpass -p password Use $() instead of ` eg for server in $(cat server-list.txt) Finally Some echo statements in your script P.s. This question would be better over at SuperUser


1

The variable '$?' stores the result of the previous command. 0 = success 1-127 = documented error (-128)-(-1) = OS killed the program with some signal So perhaps: sshpass -p password ssh root@$server /sbin/reboot if [ $? -eq 0 ]; then echo "$server - Successfully rebooted" else echo "$server - Failed to reboot" fi


0

Another solution is just simply add shopt -s lastpipe before the while loop. I say, if the trouble comes cause the while is in the last segment of the pipeline, and in Bash all the commands in a pipeline exeutes in a subshell in a separated process, then, using the lastpipe will execute the last command in the pipeline in the foreground. For example: CNT=0 ...


0

please use the -d option of xargs --delimiter=delim, -d delim Input items are terminated by the specified character. The specified delimiter may be a single character, a C-style character escape such as \n, or an octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command. Multibyte characters are ...


0

I recently had the same problem. IMHO, trying to write a shell script to do it is painful, and it is much easier to write some reusable logic using a higher-level language with builtins like sets, dictionaries, etc. The general idea is to take configuration indicating how many files of each period you want to keep, and then decide for each file if it should ...


0

Untested for file in report_*.txt; do owner=$( grep -Po '(?<=this report was prepared by=)\w+' "$file" ) echo mv "$file" "${owner}_$file" done If the results look OK, remove "echo"


0

Use ts command from moreutils (apt get moreutils). $ ls -1 | ts Oct 12 20:09:27 ts-out.v37mPS Oct 12 20:09:27 ts-out.vavMYs Oct 12 20:09:27 ts-out.wd9G1Y Oct 12 20:09:27 ts-out.ym8aN0 Oct 12 20:09:27 ts-out.zCzWhY


0

I would try to figure out the $PATH of the first user which code echo $PATH switch to the second user and PATH=$PATH:/PATHTOCODE;export PATH and see if that works.


1

okay. the sed option works. i'd mistakenly confused my slashes, but they are correct and works perfectly. i'll leave this up in case anyone else has a similar questions, but if admins want to turf it, so be it. php -f myFile.php | sed 's/<br>/\n\r/gp'


0

Butterfly Backup is nothing more than an rsync wrapper. Use the --link-dest flag to create hard links on files. Most likely, the file system where you are placing your catalog does not support hard links. I have a Butterfly Backup server with its catalog in an ext4 file system, and I have no problem.


1

I have noticed that using xargs with printf works well and is fast. timestamp="$(date -Iseconds)" ls | xargs -d '\n' -l printf '%s: %s' "$timestamp" 1>&2 I write to stderr just not to pollute the stdout. I have made a logging utility written in bash that I use in my bash scripts: https://github.com/bas080/logger It has more ...


0

Generally i would avoid to execute root privilege commands with webservers/php-fpm. So think about, if you really need it. To run this kind of job successfully with your already present scripts, you need to add the user under which your webserver runs (generally www-data) to your sudoers file and allow it to run your the command with sudo without password ...


1

So the problem here is that SELinux is not allowing Nagios to do a variety of things which, presumably, you actually want it to do (such as running ssh). It's impossible for the distribution to guess at all the things you might need Nagios to do, so while the SELinux policy allows most things related to monitoring, it isn't allowing these things. You can ...


1

I was facing a similar situation where I had to delete Docker Container Logs with ".log" extension using a command or a shell script (it was scenario-specific) Here's the script #!/bin/bash #SHELL SCRIPT TO DELETE THE CONTENT OF THE DOCKER CONTAINER LOG FILES #Declaring Array file_list=() #While loop to read log file name while IFS= read -d $'\...


0

Your script specifies set -e, which causes the shell to exit if any command in the script returns an error. If you omit this, then by default the script will continue if any command returns an error. If you wish to keep set -e and only continue if specific commands return an error, you can make the script ignore the errors from a command by using the ...


Top 50 recent answers are included