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

learn more… | top users | synonyms (1)

2
votes
1answer
877 views

Calculate average of every 5 samples with rrdtool or other languages

I want to make an average of 5 samples and calculate a single value: Current output - I put resolution of 5 minutes but receive 5 samples: $ rrdtool fetch file.rrd AVERAGE -r 300 --start 1200000000 ...
1
vote
1answer
32 views

Is using su to drop root in shell scripts a security risk?

When searching for how to drop root permissions in shell scripts, I often see answers using su. However, when you're done using su you can just type logout and be back at the shell of the original ...
1
vote
1answer
51 views

WP-CLI doesn't run from cronjob

I made a bash script that uses WP-CLI and was intended to run from a cronjob. It runs fine from SSH, but fails when run through cron. During debugging I discovered that it was the WP-CLI part that ...
1
vote
1answer
55 views

SSH issues: keyfile and host file not working as expected

When I login to server with a key ssh -i /home/me/.ssh/id_rsa server everything goes without glitch. The key is authorized on the server. However if I try to do same from a shell script, I get a ...
1
vote
1answer
37 views

name of script within a init script

I have a script /etc/init.d/startup, where I do the following: creating a PID file that should look like: /var/run/**startup**.pid executing a screen of a java process, so I will like to create the ...
1
vote
1answer
56 views

crontab truncates file path

I try to run the following command: crontab -u root /root/iss/current/node/bin/installers/nl_brandless_selector_full_hd/nl_brandless_selector_full_hd_cron_file But I got an error like this: ...
1
vote
1answer
202 views

OSX - How can I copy a local users settings/preferences to a new mobile user

We are working on migrating all our local users to mobile accounts that are bound to LDAP. I am working on a script that prompts a user to enter their email and it creates a new mobile user and then ...
1
vote
1answer
171 views

Bash script for updating multiple servers not accepting RSA keys

In my environment I manage about 10 Linux servers that require regular package updates. I have a script written to connect to each individually and run the update. Additionally, I have RSA keys ...
1
vote
1answer
738 views

Dovecot quota-warning.sh not being excecuted

I would like to run a custom script with dovecot once the user reaches certain percents of their quota. The issue is that no matter what I try dovecot does not seem to execute my bash script. ...
1
vote
1answer
107 views

What is the Linux command to get the current PPTP ip address?

I have a Linux script that allows me to route some traffic through a VPN interface, and other traffic (from different IP) through another interface. This is my script: echo "ip route del default via ...
1
vote
1answer
71 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 ...
1
vote
1answer
161 views

How can I measure the cumulative network usage of a process, from execution beginning to end

I want to measure how much bandwidth git pull uses, preferably by prefixing git command with desired program, i.e. nettally git pull Alternatively, is there some sneaky way to accumulate nethogs / ...
1
vote
1answer
258 views

Using exclamation marks in bash expansion

In bash, I build a svn command as a string with username and password options dynamically added. Some users might have an exclamation mark in their password, which might result in the following: ...
1
vote
1answer
129 views

Remote rename of a file on Samba share via Bash script

I'm running a Bash script under Cygwin, but this question applies more broadly. I have a remote file: //someremoteserver/somefile.db That "//" path is under Cygwin--it's essentially a UNC pathname ...
1
vote
1answer
906 views

Problems in monitoring file age with nagios (command substitution in filename)

In my current nagios installation I check for the existence of a remote backup through NRPE. In particular, my remote nrpe.cfg (on a Ubuntu 8.x) is: ...
1
vote
1answer
438 views

Autocompletion, history and scrolling in Byobu

I am using an Ubuntu server with Byobu. For some reason, the tab key writes a tab instead of completing commands and paths. Top arrow writes ^[[A instead of the command history. Scrolling writes ^[[B. ...
1
vote
1answer
157 views

export_bashrc() bash function to export .bashrc to a server

I am trying to write a bash function shown below.I am trying to scp my .bashrc to the target machine.I want to do modify the following function in the below two ways. 1.I want to enter the password ...
1
vote
1answer
206 views

Redhat 5 Upgrade / Sphinx Search Init Startup Hangs

I recently upgrade a VM to Redhat 5 and moved Sphinx Search to that server. For some reason when I try to start Sphinx, the startup script fails to push the searchd process to the background. I ...
1
vote
1answer
385 views

pbs/Torque interactive jobs: bash trick to run command after launch

I'm using pbs interactive jobs in bash, launched using qsub -I, and I'd like to run some command after launch. After this command is run, I'd like to continue to use the interactive reservation as ...
0
votes
1answer
15 views

Nginx how to run shell script on page load via lua module os execute and then serve directory listing?

So I have a bash script that I want to execute/run on each "page load" of url so that it will modify (creating symlinks) to a /public/html/ folder that I want the server to then serve. The problem ...
0
votes
1answer
18 views

Logrotate executes postrotate even if file not rotated

I have a problem with my rsyslog and imfile that fails when one of my log file gets truncated.. So to workaround the problem I have modified the logrotate script as follow: ...
0
votes
1answer
29 views

linux-tomcat - add command to startup.sh

How can I add a command at the end of the tomcat startup.sh script to execute a file. I think it is something like this. Assuming my file needs start as command passed to it below: exec ...
0
votes
1answer
37 views

Issue with Bash Script On FreeBSD

I have the below bash script set to run every hour via cron as the root user. The purpose of this script is to email us when files have been uploaded to our sftp server and send us the logins. Here is ...
0
votes
1answer
53 views

How to automate input for a repetitive script! Expect in Bash?

I am a junior sys admin. Reason I'm asking this question is because we don't have a senior sys-admin here who is proficient with scripting. Senior guys are at the head office and too busy for ...
0
votes
1answer
57 views

How to use environment variable in haproxy?

I work with haproxy 1.5.2 My haproxy.cfg has this server definitions: server HALB_ucd1 ${UCD1_END_POINT_IP}:${UCD1_END_POINT_PORT} check port 8444 I set the UCD1_END_POINT_IP and ...
0
votes
1answer
47 views

catch bash script output from expect, expect hangs

I currently use expect to pass password to rsync to copy files across unix servers test.sh ./expect.sh $password rsync -azvr $username@$host:$file ./$dir expect.sh #!/usr/bin/expect -f ...
0
votes
1answer
24 views

lvm clone logical volumes layout to another host

I want to clone LVM logical volume layout to another host ( = Create volumes with same size ). Does anyone know solution for this ? I know I can execute something like: sudo LC_ALL=C lvs -o ...
0
votes
1answer
37 views

rsync not behaving the same in script vs shell

Afternoon ServerFault, I have hit a problem that I can seem to reach a solution to, I currently have a backup script that is meant to rsync VMs off our VMWare box onto our backup server, the problem ...
0
votes
1answer
59 views

How can I tell a script is running under cron?

Is there a standard way to know if a shell script is running under cron as opposed to running from the command line. i.e. I'm thinking of running with more verbose output when manually kicked from the ...
0
votes
1answer
78 views

Script to Push Files

Script to Push Files Hey Guys, Thanks for always being helpful, I have another issue that I need a little insight on how to fix. See the below script I have and the error I get. I don't understand ...
0
votes
1answer
104 views

Efficient way to parse Apache Access Log for CMS logins

I've been working on a way to parse large multiple access logs (sometimes in double digit GB in size) for CMSs. Right now I just need WordPress and Joomla, but I know the types will grow over time. ...
0
votes
1answer
226 views

Monit failed to start shell script

So I am having a problem with monit starting a process this is my code: check process program_1 matching "program_1" start program = "/home/user1/files/start.sh" stop program = ...
0
votes
1answer
143 views

Execute a service as a specific user under ubuntu

I'm running a gameserver and want to start it on a screen on system start, but screen is user specific, so I have to run the command as 'user'. So I wrote this short service script which starts itself ...
0
votes
1answer
162 views

Cron occasionally fails with “grandchild #X failed with exit status 3”

I have cron jobs and every now and then they fail. Just after log message that the command has started, there is grandchild #X failed with exit status 3 message. On the next run scripts finishes ...
0
votes
1answer
43 views

NUT UPS: stop specific service on power failure

Does anybody know how to stop a service when there is a power failure using NUT? I made a custom script like this, the problem is that the script user (NUT) does not have root permissions to stop the ...
0
votes
1answer
346 views

Updating a Vyatta 6.6 box for Shellshock

A client has a few Vyatta installations that they're eventually wanting to replace with VyOS. In the interim, they're running Vyatta 6.6 (last version prior to the sale to Brocade). It's an internal ...
0
votes
1answer
223 views

Getting the passphrase to ssh-keygen

I have a new private key that I'm bringing to a docker container as part of a bash script. After copying the private key to /root/.ssh/id_rsa I wanted to regenerate the public with: ssh-keygen -yf ...
0
votes
1answer
348 views

segfault error with bash on CentOS 6

I updated bash as soon as both patches were available, and using the test script at https://shellshocker.net, I am showing fixed on all vulnerabilities except for segfault. OS: cat /etc/*release* ...
0
votes
1answer
89 views

“File not found” from bash script executed by Apache (CentOS)

I have a bash script that sets up a classpath for accessing a series of JARs (it's tf, the cross-platform, command line tool for Team Foundation Server). The file structure is something like: ...
0
votes
1answer
59 views

Password less mysql access to specified user/script only

In addition to this question: Performing root mysql operations in bash scripts I'd like to ask how to limit/allow this action (performing root administrative actions): mysql --local-path=mypath -e ...
0
votes
1answer
101 views

Cron bash script skips second do/done set

I have a script that checks IPs for ping reply then tries to run an snmpwalk on them. I am trying to schedule the script to run weekly in cron. When I run the script in the shell, it runs perfectly. ...
0
votes
1answer
68 views

init.d script appears to run but dies immediately

I registered the init.d script and when I invoke this directly /etc/init.d/gae it appears to work...PID file is created but the process is no where to be seen by the time I do a ps I have googled and ...
0
votes
1answer
652 views

How to delete all ufw rules for a certain port?

I am using ansible to configure ufw on my DB servers to only let accept connections from certain servers connection to a specific port (lets say 1234). When a server that used to have access is taken ...
0
votes
1answer
65 views

Binding timestamp value to a variable in crontab

I'm basically trying to declare a variable with a date() value in crontab as I will constantly be using the same date structure over and over, here is what my crontab looks like so far. php = ...
0
votes
1answer
422 views

Unable to clear sendmail mqueue-client

drwxr-xr-x 2 smmsp smmsp 4.0K May 6 23:31 mqueue drwxrws--- 2 smmsp smmsp 29M May 8 10:40 mqueue-client As you can see mqueue-client is filled with 29 megabytes of unsent mail. This seems to ...
0
votes
1answer
893 views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
0
votes
1answer
28 views

prepare domain list to work with squid 3.x

the latest version of squid do not accept duplicated domains like: example.com pre.example.com --- this is no longer necessary and it requires domains to start from "." adding dot is simple: ...
0
votes
1answer
86 views

Netcat: connection lost before transfer is complete

Interesting thing with Netcat (nc) in CentOS 5 or 6 (nc-1.84-10.fc6 or nc-1.84-22.el6.x86_64). How can I work it around? I can't find a bug about this, but It models a file transfer to a remote ...
0
votes
1answer
263 views

Unable to get cron to append output from wget

I have a cronjob setup and running, but the logfile keeps getting overwritten every time it runs. I would like for the wget output to be appended each time the cron runs. Why is this and how do I fix ...
0
votes
1answer
46 views

Include executed cron command when outputting to log

Is there a way I can include the command that was executed in the output when I'm logging to a file? For example: * * * * * date && /path/to/php /path/to/script.php >> cron.log ...