Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

learn more… | top users | synonyms (1)

2
votes
1answer
237 views

Terminate remote process when backgrounded ssh session is terminated

So right now I have a bash script that runs a command on a remote machine using ssh. The machine running the bash script is a Linux machine and the remote machine is a Windows machine running cygwin. ...
2
votes
1answer
107 views

BASH: alternatives to coproc [closed]

I have some scripts which use coproc to control stdout/stdin of subprocesses. Unfortunately, coproc was introduced in Bash 4.0, and on many systems I use, there is an earlier versions of bash. Are ...
0
votes
2answers
160 views

Script for search string inside the file for every one hour

I need to write a script where the particular string(alphanumeric) should be searched inside the file with every hour for whole day. And the search should not contain the previous hour results. Time ...
3
votes
2answers
169 views

How to parallelize the for loop while scp the files?

I am running my below shell script from machineA which is copying the files machineB and machineC into machineA. If the files are not there in machineB, then it should be there in machineC. The below ...
2
votes
4answers
144 views

How to migrate ssh key to new CentOS server?

We have lots of scripts that run over ssh through saved (passwordless) key pairs. Both clients and servers are CentOS 6.x.I know that if you get a new client computer (where the scripts are run from), ...
3
votes
2answers
2k views

How to keep: daily backups for a week, weekly for a month, monthly for a year, and yearly after that

I need to backup data and config files on this server, daily. I need to keep: daily backups for a week weekly backups for a month monthly backups for a year yearly backups after that All of this ...
0
votes
1answer
283 views

How to create ssl certificate for multiple domains which requires the CA root key in Linux

I have mail server. There are may domains hosted on it. I am deploying ssl certificate on it. I want that when user access there mail account using https browser should show that certificate is ...
-1
votes
3answers
49 views

How to create batch of specific number of lines in linux [closed]

I have a 10000 lines file.I want to create batches of 100 lines at a time in each different file.I know that this can be done using a while loop.But, I want to know whether it can be directly done ...
1
vote
3answers
120 views

My init script not showing up in service autocomplete

I made a init script for a ghost website. I'm using Linux Mint 16 (aka Ubuntu 13.10) When I type this, my script doesn't show up in autocomplete. sudo service f<tab> Any reason why? I get ...
1
vote
3answers
119 views

Completely reset PostgreSQL to default?

Question Is there a way to completely reset a PostgreSQL installation on Linux, so it is in the same state as when I installed it? Idea I have considered rm -rf /var/lib/pgsql/* rm -rf ...
16
votes
2answers
1k views

Is there a bash builtin for 'which'?

I've been testing a minimal Fedora install. To check the path for interpreters like python or node, I normally use which. I notice which isn't installed by default. I could add the package, but I ...
0
votes
1answer
46 views

Trouble with $PATH on debian

I think I have a problem with $PATH. I am running a shell script and it is complaining that it doesnt recognize the command even though when I run it manually it does. Shell Script: #!/bin/bash # ...
1
vote
2answers
262 views

permission denied in running script

I am running a script but there is an unusual warning: This is what happened in my console #whoami root #ls -l test.sh -rwxr-xr-x. 1 root root 1894 Feb 2 01:58 test.sh* #./test.sh -bash: ./test.sh: ...
0
votes
2answers
172 views

How to remove all messages from exim mail queue from a certain user/email

I've spend the last hour trying to figure out how to delete all messages from a certain mail address from the exim mail queue, after the queue was full of spam emails.
1
vote
2answers
364 views

Linux Bash IF conditions not processing when running as crontab

So I've made myself a little script which monitors my served directories for any PHP files which have changed. It's designed to run every 5 mins from crontab and email me any changes so that I can ...
1
vote
1answer
60 views

Bash: delete old files except one

I am using the following command to delete old backup files: find backups/ -name "bak_*.tbz" -mmin +4800 -exec rm -vf {} \; The problem: When there are no new files, than all files are deleted. I ...
1
vote
2answers
60 views

Dynamically remove iptables policy by IP address

I would like to remove some NAT POSTROUTING rules in an automated fashion based on the source or destination IP address. I know the source and destination IP but I don't necessarily know which ...
0
votes
2answers
48 views

Tinydns data file change ip with bash

I am using tinydns and need to dynamicly change some ip in data file. I want to use bash script for it. For example data file: +sub1.example.org:282.196.222.245:14400 ...
0
votes
0answers
29 views

Use tmux for managing multiple downloaders as a supervisorctl service?

I have many data-servers I need to download data from via http as soon as it is available. For each server I start a bash "while true"-loop and within that a wget to poll the server for new data. To ...
0
votes
3answers
749 views

zcat/gzcat works in linux, not on osx. general linux/osx compatibility

First the specific problem: In linux, I use zcat to list a .zip file. In osx, zcat seems to automatically append .Z to the file name. Various people suggest replacing zcat with gzcat; however, gzcat ...
0
votes
2answers
794 views

ulimit -n not changing - values limits.conf has no effect

I am trying to raise the open file descriptor maximum for all users on an ubuntu machine. This question is somewhat of a follow up to this question. open file descriptor limits.conf setting ...
0
votes
1answer
310 views

“Long service output” in Nagios gets chomped for some reason

According to this page the limit of $LONGSERVICEOUTPUT$ is 4kB, but in my case, it stops showing the rest of the output after 970 bytes of output (26 lines), where there multiple newlines no long ...
-3
votes
1answer
431 views

Unexpected EOF while looking for matching ``' - Bash Script

Here is my bash script: http://pastebin.com/9kgGYPmt Ok so simply, when I run the Bash command I get this error: http://puu.sh/6oSTW.png I really don't know why this is happening. Can anyone help? ...
0
votes
0answers
95 views

Using Jekyll with Github webhooks for automated deployment

A little background first: I'm a designer and want to serve some static sites with Jekyll. So I grabbed a vps(ubuntu 12.04) and installed nginx, ruby and jekyll. I work from a few different ...
4
votes
2answers
341 views

How to handle IP's with manual failover?

I have two identical storage hosts where the master is the only one the users can access. If the master fails, then I want to manually change the DHCP address, so instead of master points to ...
2
votes
1answer
46 views

Command which will tell me the last time a directory or any of its sub directories have been modified? [closed]

We are trying to deprecate our old Linux home folder server. We still have a few people that are actively using it though. Our plan is to change home folders that no one has used in the last six ...
1
vote
1answer
453 views

Centos syslog isn't logging to custom file from bash script

I'm trying to get a bash script to log to a custom log file using syslog on Centos release 6.5, but it always just logs to /var/log/messages like so: Jan 12 09:54:47 localhost nbsp: Test message ...
2
votes
0answers
17 views

Globally recording Bash history: Dealing with long-running commands [duplicate]

For security reasons, I'm trying to remotely log all commands that users enter into the shell. I've got it to work by using this in my global bashrc: PROMPT_COMMAND='history -a >(tee -a ...
0
votes
2answers
68 views

Why does system lag or stall after successful completion of tar backup command?

I have a script that runs backup of system files via tar as a cronjob for my server. Every time the script is being fired off, it completed the task as successful. All backups were tested and appeared ...
0
votes
1answer
61 views

Binary data in shell argument

Is there a way to safely encode / pass arguments to a shell command where the argument might be binary? I'm executing a command from within a PHP script that allows for user data. For security, ...
2
votes
4answers
205 views

Use logger in shell script

How can I use logger in a shell script? If I run ntpd -qnp pool.ntp.org 2> >(logger) in console, it works as expected. If I put it into a shell script #!/bin/sh ntpd -qnp pool.ntp.org ...
2
votes
3answers
161 views

How to parallelize the scp command?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
2answers
222 views

Gnu parallel & pipe

I want to send each line of a file to another program's stdin, e.g. input.txt line1 line2 line3 I want to use the gnu parallel like this (i.e. pipe each line as stdin to the more command) cat ...
1
vote
2answers
113 views

How do I iterate bash arrays and make an SCP command efficiently?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
2answers
89 views

Redirect to stdin instead of argument when using xargs [closed]

for exmaple, using the command cat foo.txt | xargs -I{} -n 1 -P 1 sh -c "echo {} | echo" The foo.txt contains two lines foo bar The above command print nothing.
0
votes
1answer
349 views

sh bash script ambiguous redirect pid of file using single quotes

I have the following new line in my .sh file su --session-command='$javaCommandLine & >>$serviceLogFile 2>&1 & echo \$! >$pidFile' $serviceUser || return 1 When I had it ...
0
votes
5answers
480 views

Bash script to check if a public HTTPS site is up [closed]

I'm trying to setup another block of code to a bash script to check if a public website on HTTPS is up or not. Can we do this using CURL? Any suggestions what can be used besides CURL. Thanks
1
vote
1answer
49 views

How is the . operator related to | and >?

I'm writing a script that transfers files that are periodically added to a remote server. To do this I'd like to pull ls output from the remote server, then check it against a list of files that have ...
1
vote
1answer
57 views

Script won't do what it should when run with cron

I've got some problem. I have script execution scheduled but when time comes nothing happens. #!/bin/sh TIME=`date +"%d-%m-%Y"` cd /var/www/flyer/data/www/ mysqldump -u root -ppasswd --databases ...
1
vote
0answers
69 views

linebreaks between results in grep

I need to occasionally monitor a spider that I have running on my server. I'm testing it to see how many iterations of it are running concurrently and to see if any of them are hanging. I use this: ...
1
vote
0answers
103 views

SNMP error reporting to stdout

Why does net-snmp after "No Such Object available on this agent at this OID" errors exit with 0 and print the error message to STDOUT while other errors are printed to STDERR and have an exit status ...
-1
votes
2answers
65 views

Compare installed rpm packages with available?

I would like to find the vmware packages that I haven't installed from their repo. The problem is that the output of yum search vmware is not the same format at from rpm -qa|grep vmware. Question ...
3
votes
3answers
816 views

Log commands executed over ssh

I would like to log all commands executed over SSH. Say, ssh something@server.com COMMAND I want to log "COMMAND" on server.com I did search extensively but could not find anything. There is ...
1
vote
3answers
220 views

How to add SSH known host in a bash script?

I am creating a bash script to provision a new server that I can deploy a web application to. One thing I always have to do is as GitHub as a known host using ssh git@github.com. How can I automate ...
1
vote
3answers
180 views

How to accurately check if package is installed in yum?

I keep getting answers like: yum list installed | grep bind or rpm -qa | grep bind But that is not accurate as I'm getting a list of few other bind packages like these: ...
-1
votes
1answer
333 views

Bash : Reload home directory (/etc/passwd) without logging out

I'm on a Debian Wheezy, and I'm wondering how I can, after editing /etc/passwd (actually to change a home directory, but nevermind), reload the user session without logging off. I tried exec bash, ...
1
vote
1answer
827 views

Insserv rejected the script header

I was trying to make an init script for my debian install for supervisor. insserv: Service \$remote_fs has to be enabled to start service supervisor insserv: Service ...
1
vote
1answer
50 views

cp/rsync command with destination as symlink to a directory

I am working on a cPanel backup solution at the moment. We are now informed about this exploit. Exploit : Full ROOT ACCESS to server 1.) create malicious file from, normal user account: mkdir root ...
0
votes
1answer
163 views

nagios bash script/command returning null

I wrote a simple nagios command to check the change of a value over 1 second #!/bin/bash HOSTNAME=$1 COMMUNITY=$2 OID=$3 WAITTIME=1 echo "/usr/lib/nagios/plugins/check_snmp -H $HOSTNAME -C $COMMUNITY ...
2
votes
2answers
174 views

executing .bash_profile alias via SSH

I would like to remotely execute a .bash_profile alias, but I cannot find the proper command. I tried: ssh user@host "bash -ic myalias" but it doesn't work I get: bash: cannot set terminal process ...