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

learn more… | top users | synonyms (1)

18
votes
2answers
3k views

Will Ansible prevent the execution of 'rm -rf /' in a shell script

This is based upon this hoax question here. The problem described is having a bash script which contains something to the effect of: rm -rf {pattern1}/{pattern2} ...which if both patterns include ...
2
votes
1answer
35 views

unix utility to limit the number of bytes placed into a bash variable

Is there a unix/linux utility, perhaps a shell builtin or an external command, that will limit the number of bytes placed into a bash variable? For example, I want to make sure STRING gets at most ...
5
votes
2answers
138 views

Cat, Grep, Redirect Output… Blank File?

I just ran cat /opt/webapplications/Word/readme.log | grep -v 'Apple' and I got the output on the cli that I was expecting, which was all the lines in readme.log that did not contain 'Apple'... ...
1
vote
1answer
54 views

Ansible & rbash

I want to manage a bunch of devices running /bin/rbash as the default shell with Ansible. The problem is that Ansible always tries to execute a list of commands that rbash doesn't like at all: umask ...
0
votes
0answers
24 views

Cacti poller runs but not full script

I'm using Cacti and the poller calls a bash script to get some data. At the end of this script I have a logical test and then an email is sent if true. The issue I have is when the poller is running ...
0
votes
0answers
26 views

“-bash: fork: retry: …” on SSH connection

When I'm connecting via ssh to my useraccount of my server, I'm getting the following error: -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable Does anyone ...
0
votes
3answers
56 views

Bash if condition to check if a ubuntu package needs an upgrade?

I need a bash line to check if a ubuntu package needs an upgrade or not. For example, I want to check if the package 'firefox' needs an upgrade using dpkg or apt-get commands. Hypthetical Example: #...
0
votes
2answers
198 views

Unable to run a python3 script in CentOs7 [with python2.7] via cronjob

I have been trying to deal with this strage problem all morning. I have a simple crawler.py file, which contans a code that can only run under python3 to be exact under python3.3 evenrionment Now, ...
2
votes
2answers
61 views

printing user of subshell obtaining root via su -

Can I print the username which is obtaining root access via su - on the root console upon obtaining root? user1$ su - password: obtained root via user1 #
0
votes
0answers
8 views

su rails session mysteriously closes by itself

I need help troubleshooting a strange problem. When I ssh into a server I have and do an su rails from root user the session closes by itself: root@ubuntu-server:/4# su rails rails@ubuntu-server:/4$ ...
1
vote
1answer
77 views

ansible custom facts returning string not array

I have a custom fact for my servers to retrieve customer data. This works fine on the machine and returning valid json. I can write the output to another facts-file and this works perfectly fine too. ...
1
vote
0answers
37 views

Linux ramdisk transfer files on reboot [closed]

I've created a tmpfs ramdisk, which is mounted at boot through /etc/fstab. The ramdisk should be used to serve content to an apache web server running on the machine. Is there a simple way to ...
-1
votes
2answers
34 views

Job control: How to kill a sudo job using the job id

If I run jobs with sudo I can't kill %1 them (Operation not permitted). My first thought was to use sudo kill %1 instead, but that of course doesn't work either because it won't use the bash builtin ...
0
votes
1answer
64 views

Installing a software in multiple linux machines using shell scripting in one machine

I will login to one Linux instance using ssh - putty and my goal is to install a software (for ex: I need to download oracle and install it) on 5 Linux machines with one shell script when I run that ...
1
vote
0answers
23 views

Deleting files from Remote FTP-Server older than X days (only ftp, curl or lftp) [duplicate]

I have similar situation descibed here: Deleting files from Remote FTP-Server older than x days and I see this is not answered fully yet so I would like to register the new one. My files are having a ...
1
vote
1answer
44 views

nginx - How often was accessed to specific file or path? [closed]

I'm looking for a command/line to get the information how often was a specific file/path accessed from the web-server. (source: default access-log from nignx) It should check all logs (current and ...
1
vote
2answers
41 views

Script to combine data from one file to another [closed]

I have a file containing folders name/value pairs: peter:/home/peter/ max:/home/max-lucas/ judith:/home/judith/documents/ I have another file containing files name/value pairs, with the same ...
-1
votes
1answer
35 views

Cronjob doesn't run. Similar cronjob does run. Issue with Env Vars??? Fedora involved. psql involved [duplicate]

I have cronjobs like so * * * * * /usr/bin/psql -U usename dbname -c "select usename, now(), pg_terminate_backend(pid) from pg_stat_activity where state like 'idle%' and (now() - query_start) > ...
12
votes
4answers
1k views

How do I recall a specific command from command history, without executing it

For example, in bash I can type !xyz which will run the last command I typed beginning with xyz. How can I bring up the last command I typed beginning with xyz but without executing it? e.g so I can ...
0
votes
1answer
26 views

Variables lost outside loop

I am trying to backup my DB using mysqldump, while ignoring some tables defined in a variable, but while looping, I got the last table name, it was overridden, how can I store tables inside a variable ...
0
votes
1answer
31 views

Convert $no_proxy to gsettings ignore-hosts

In order to use Chrome in Ubuntu and have it respect some hosts in $no_proxy, I need to set those comma-separated values with gsettings set org.gnome.system.proxy ignore-hosts <no-proxy> where ...
0
votes
2answers
71 views

How to autocomplete long file names in terminal

If I have in current directory a file with a long name starting with "build" I can write in console "build", press Tab and autocomplete type full filename for me. However if I have multiple files ...
2
votes
2answers
75 views

Command prompt taking too long to appear after ssh connection

I have a server that is acting really weird and hopefully you will help me find out what is happening. Here are the facts: The server has 2 users: root and myuser The server accepts only ssh ...
-1
votes
1answer
49 views

create an array of dates in bash scripts and match it with current date [duplicate]

Actually i want to create an array of dates and compare it to the today date if it match with the current date then execute test.sh file otherwise exit the loop in bash script. I did like this... **#!...
-3
votes
2answers
56 views

How to compare today's date against an array of dates [closed]

I want to create an array of dates and compare it to today's date if it matches then execute test.sh file otherwise exit the loop in bash script. I have this so far: #!/bin/bash now=$(date +%Y-%m-%d) ...
0
votes
1answer
51 views

remote SSH command works but not when used in bash script

I am trying to stop tomcat on a remote server using a bash script. Here is the function: function stop_remote_tomcat () { CURRENT_SERVER=$1 CURRENT_USER=$2 CURRENT_PEM_FILE=$3 ...
-4
votes
2answers
45 views

execute bash script on last thursday of every month [closed]

Actually i have a bash script file and i want to execute it on the last thursday of every month please help me to find out the proper solution of that problem using bash scripting.
0
votes
1answer
139 views

How to combine lsof stat and ps to get more info in one line bash command

I can use lsof to get top open files stat for processes, as below: $ lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr | head -n 5 17955 11945 10282 2786 5980 32152 1920 27803 1786 32107 ...
0
votes
1answer
167 views

Expect script too fast: add a sleep between each line read from a file

I am trying to automate switch commands. It's almost all good, but when the expect script reads each line from the file containing my switch commands (listed line by line), the switch seems to stop ...
0
votes
0answers
60 views

Python script to delete HPSA RHEL software policy items(rpms)

I'm looking to script the deletion of HPSA software policy items (RHEL RPMs) from HP Server Automation server. In our environment we have "HP Server Automation 10.22", using rhn_import command we ...
1
vote
1answer
25 views

Run command in screen when LSB initscript stopped

I'm trying to get a Bukkit server to run inside a screen as a service, started from an LSB script but I cant get it to stop correctly. What I essentially want it to do is reattach the screen and send ...
0
votes
2answers
264 views

How to zip files with a size limit?

I have a script that zip files from a folder. I want to make sure that the zipped file is not more than 10 MB. If the size is more than 10MB, it should create another ZIP file. Is there any command (...
2
votes
2answers
229 views

Allowing httpd to run a bash script in /usr/bin/

Migrating a system from CentOS6 to RHEL7 with SELinux running Enforced. A php script makes a call to /usr/bin/processdata.sh to generate some data behind the scenes. This worked fine with the old ...
2
votes
3answers
52 views

Bash for loops and hostnames and how to generate them

Why doesn't this work? NODE_ROOT=node0 INFRA_DOMAIN=example.com for host in $NODE_ROOT{1..3}.$INFRA_DOMAIN; do echo $host; done I'm expecting: node01.example.com node02.example.com node03.example....
-1
votes
1answer
38 views

Predict: fork: Cannot allocate memory

Using many bash parallel processes: process1 & ... process30 & Doing multiple git operations within each process randomly will produce: fork: Cannot allocate memory The system is CentOS ...
0
votes
0answers
36 views

nginx stop logging after crontab modified the log file

I have a web server(django) running on nginx + gunicorn. nginx writes its regular logs to: ~/myproject/log/access.log and it writes errors to: ~/myproject/log/error.log it works pretty well for ...
1
vote
1answer
96 views

Is there a way to make these two docker bash commands execute synchronously?

I am automating the setup of dev environments for my app and when I run these two commands manually from the command line I have to wait around 10 seconds after running the first one to run the second ...
0
votes
2answers
42 views

Is it possible for a child script to write output to a parent process?

I have a notify script kicked off by keepalived daemon process whenever it's state changes. The problem is, echo output from my notify script does not appear in the output displayed when running ...
1
vote
0answers
36 views

How to get the output of the python script executed in aws instance

I am trying to automate the aws instance setup using boto. I have a python script in which I will do the ssh to the instance. After ssh,I am executing a python function which is in remote python file ...
1
vote
0answers
43 views

How to display init output to tty7 (or main tty)

I have created my first init script in a linux server (ubuntu if that adds any information) that checks for an update, downloads it and executes it in each hour. The init file is as follows: /etc/...
1
vote
1answer
148 views

Difference between sudo /bin/bash and sudo su to access root

I am aware that there are at least 2 ways to escalate to root privileges when in the terminal, and am genuinely curious as to whether there is a differences / are differences as to what can be ...
6
votes
1answer
74 views

Ensure that no console sessions are left logged in (Linux)

On a Linux system with bash as a default shell, I want to configure automatic logout with the following criteria: Console sessions (VGA, serial, remote KVM, etc.) are logged out after a specified ...
0
votes
1answer
51 views

printing a children's full tree recursively in bash script

sry for not being familiar with question conventions since im new here. i want to write a script that prints the full children's tree recursively of a given pid. i got so far as: ps h -ef | awk '$...
3
votes
1answer
72 views

Strange behaviour ssh -> bash --> (tty no echo) --> c program?

At job we have an old C program which works with industrial hand terminals from Honeywell. That terminal has its own ssh client to connect to a linux redhat 6.6 server. Once it is connected to the ...
1
vote
0answers
17 views

Generating and testing variable from a MAC vs PC in Linux Bash script

I am supporting two groups. I have one script, and I would like to keep it at one. I am having trouble with a test function: convtype=./Sample*/ if [[ -n convtype ]]; then where it runs fine for ...
7
votes
2answers
390 views

Why does `crontab -` remove crontab, and can it be cancelled?

I hurried and forgot the e in crontab -e before I hit Enter. A prompt appeared, so I closed with Ctrl+D, same as I usually exit input prompts. Now, without warning, my entire crontab is empty. ...
0
votes
0answers
69 views

Interpolating bash variable containing quotes into a command breaks it

I'm trying to split out some parts of a docker command that I have into bash variables. What I had previously, works fine: DOCKER_ID=$(docker run -e CGO_ENABLED=true -e LDFLAGS='-extldflags "-...
0
votes
1answer
48 views

Ceph installs without init scipts. How do I get them?

I have installed ceph in 3 centos7 nodes with ceph-deploy tool. All works good but I haven't any script to manage ceph or radosgw. My /etc/init.d/ folder contains only these: functions, network, ...
1
vote
1answer
31 views

Issuing a single command from a cluster of servers?

I have a cluster of servers that will be running a simple ruok command with fallover. The command will be something simple like curl -X POST http://foo.com/status. Due to the fact that I will have ...
0
votes
3answers
54 views

Matching first block of text from a file, between 2 strings

I'm trying to match only the first block of text between 2 strings: 'menuentry ' and '}' from a file as follows: Input file: (some irrelevant text) menuentry 'My Customized Linux, with Linux 3.10.0-...