1
vote
1answer
56 views

Start Unix screen, Run command, Detach

How can screen be used to start a new session and run a command within that session without killing that session? screen -S myScreenName runSomething I tried the above command and it says [screen ...
2
votes
2answers
62 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 ...
1
vote
3answers
63 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 ...
0
votes
2answers
175 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
122 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 ...
4
votes
2answers
280 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 ...
1
vote
3answers
117 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 ...
0
votes
1answer
139 views

Is it possible to auto update php.ini via a bash script? [closed]

I'm trying to write an install script and i need to change the sendmail line in php.ini but I want to do this automatically at the moment I'm doing this manually: sudo nano ...
0
votes
1answer
108 views

Tomcat error checker using bash

Can someone shed me some light, point me in the right direction? I want to create a script in bash that will checks exceptions in the logs during the startup of Tomcat app. This script should be able ...
-1
votes
2answers
53 views

Better way to exec at a specific folder

It is possible to exec at the specific folder, rather than I need to use two commands separately? e.g. cd /opt/folderA exec .... cd /opt/folderB exec ....
0
votes
1answer
34 views

How to set multiple paths with update-alternatives

For example, the following command install java to /usr/bin/java update-alternatives --install /usr/bin/java java /opt/java7/bin/java 1 && update-alternatives --set java /opt/java7/bin/java ...
-1
votes
2answers
43 views

any native disk utilization command without need to install

is there any simple bash command to show current disk read/write usage without installing anything on the machine ? please note it's not to test the hdd read/write speed, it's to know the current ...
0
votes
2answers
172 views

Strip out the 'n' \ new line out of the echo to a file [closed]

I have a bash script that pulls a bit of text from an external MySQL database. Most of the times it are 4 lines, each one on his own line. This text (in total) has to be placed into a file. The script ...
0
votes
0answers
36 views

schroot auto-mounting doesnt works?

I've been reading about schroot and trying to understand the parts in various tutorials that mention about auto mounting. For example check the section (and the parts after it) "Basic schroot ...
-1
votes
1answer
88 views

Determine which process owns an flock'ed file

I have a Bash script that runs in multiple processess concurrently. The relevant portion looks like this: flock /var/lock/my_lock my_command Given that /var/lock/my_lock exists, is there a way to ...
0
votes
2answers
59 views

Copy file to backup directory preserving folder structure

I have to copy a file in a directory, to its backup directory, preserving the folder structure. Ex. The file aaa in MyFolder/Test/aaa to .MyFolder.bck/Test/aaa I tried to use cp --parents ...
0
votes
3answers
230 views

tail-pipe-awk script, fine on Centos but weird on Ubuntu

I wrote a script on CentOS and now I'm trying to run it on Ubuntu and it is behaving unexpectedly. Here's something like the script, which I run under bash: sudo tail -F ...
1
vote
2answers
268 views

Using 'source' command in bash scripts

I am writing a bash script to attempt to automate initial setup on Ubuntu, and I have run into an issue I do not understand. If I run the following code: sudo apt-get -y update && sudo ...
0
votes
2answers
190 views

Start Linux GUI app in a VNC or RDP session for later access

Using a BASH script, I need to launch a GUI application at boot in such a way that I can later connect via RDP or VNC and see the application running. For example, the script will run at boot and ...
1
vote
2answers
159 views

Why need to use exec in upstart script?

I often see some upstart script has the to use exec, what is the point? Seems removing the exec the script also work? e.g. start on runlevel [2345] stop on runlevel [06] exec /path/to/program
0
votes
2answers
250 views

AWS-CLI - Can't find my config even through it exists

I installed Amazon Command Line Tools (AWS-CLI) using: pip install awscli It installed successfully. I then created a file in this location: /opt/aws/aws_cred.txt [default] aws_access_key_id = XYZ ...
0
votes
3answers
800 views

Cant run rc.local manually and doesn't run automatically on ubuntu

This is quite a simple one. I created an rc.local file here: /etc/rc.local I made it executable. However, it doesn't run when I boot the server. I can see it in the directory and when I try to run ...
1
vote
2answers
72 views

Strange behavior with `find -delete`

I'm using Ubuntu 12.04 with 2 x 2TB SATA3 harddisks in software RAID1. The filesystem is ext4 with data=writeback. When using find . -maxdepth 1 -name '*' -delete to delete a large number of files in ...
6
votes
1answer
189 views

How to start netcat in listening mode from another host?

I have a script where I would like to start nc in listening mode on 10.10.10.11, but I would like to do it from 10.10.10.10, where I have this script ssh -n 10.10.10.11 nc -l 8023 | mbuffer -s 128k ...
1
vote
3answers
242 views

Possible to kill command after a timeout if not success?

I would like to use mbuffer to do ZFS replication with, but in order to do that, I have to start it in listening mode on the target host. That I would do from the master host by ssh 10.10.10.11 ...
0
votes
2answers
610 views

Good pratice to create script to start/stop/restart service?

I was wondering what is a good pratice to create a good script to start/stop/restart some service. I will try to make myself more clear, ok ? Nowadays, I do something like this: let's say I would like ...
0
votes
2answers
632 views

Output of /proc/diskstats in ubuntu

can anybody tell me about 11th field in /proc/diskstats? The documentation says that it is weighted # of milliseconds spent doing I/Os. Is it like # of milliseconds spent for DiskIO in a second? I ...
0
votes
3answers
78 views

Can't figure what's wrong with with my crontab

Due to some bug in one of my scripts i'm being forced to delete temp files every 30 minutes until i'll figure it out and debug it. To get it done i've written a small bash script that i run every 30 ...
1
vote
1answer
105 views

Setting “say” alias for espeak on Ubuntu Linux

I'm trying to make a compatible "say" command on Linux. So far this works: alias say='echo "$1" | espeak -s 120 2>/dev/null' I'm adding this to /etc/bash.bashrc. Problem is, this say is called ...
1
vote
1answer
129 views

Spanish Characters in Linux Server Bash Shell

I have a database that contains Spanish words in it. It contains words like sueƱo which have "special characters" in them. The MySQL database collation is set to utf-8-general-ci which supports ...
0
votes
1answer
143 views

Display menu instead of login prompt on Linux

After starting up a linux server (mostly Ubuntu or Debian based), I see a login prompt on the local console. To enable end users to restart such a server or start some maintenance tasks, I would ...
1
vote
2answers
99 views

How to run script from root as another user (with user PATH)

I would like to have these commands run as the ss user from root mkdir bin cp -r /opt/gitolite . gitolite/install -ln gitolite setup -pk ss.pub mkdir -p .gitolite/hooks/common ln -s /opt/pre-receive ...
4
votes
3answers
766 views

Possible to ignore the users shell in “su” command?

If I do su - -c 'mkdir bin' user1 then I get su: /usr/bin/ksh: No such file or directory because the users shell is set to ksh in /etc/passwd and ksh is not installed. Question How do I carry ...
0
votes
4answers
164 views

Sudoers file permissions

I'm trying to run the following command without the need for sudo: echo 1 | sudo tee -a /sys/block/$hd/device/delete The $hd variable changes dynamically from sdb -> sdi for each one of my HDD's in ...
2
votes
2answers
726 views

Add entire 300 GB filesystem to Git Annex repository?

By default, I get an error that I have too many open files from the process. If I lift the limit manually, I get an error that I'm out of memory. For whatever reason, it seems that Git Annex in its ...
0
votes
4answers
138 views

Assigning environment variables for CRON

I have a .sh script that creates a .tar.gz file and transfer's it to a remote server using RSA keys for authentication. The script will run from terminal but it will not when I try to set it up as a ...
3
votes
2answers
127 views

Rename a directory containing many files

I made a mistake in a rsync and all the files are copied long with its full path. All the files that I copied are at /var/www/photos/2012/1007/1007 Attempt 1 Now I would like to fix the paths, by ...
1
vote
2answers
543 views

Meaning of killall -0

I see from many place the follow command is used to check if a process exists, e.g. killall -0 nginx But from the documentation I can't see anything related to this argument, can anyone explain?
4
votes
2answers
2k views

Answer “yes” to ssh-copy-id first time run by script?

The first time ssh-copy-id it will ask # ssh-copy-id -i .ssh/id_dsa.pub backup@example.com The authenticity of host 'example.com (xxx.xxx.xxx.xxx)' can't be established. RSA key fingerprint is ...
4
votes
5answers
4k views

How do I split a string against a character in BASH?

I would like to be able to split an authorization code by the - character so that I can operate on each segment individually. I do not want to use external binaries (awk, grep) - this is to be as ...
0
votes
1answer
605 views

Where did start-stop-daemon store the pid file by default?

When I have a upstart script like.. exec start-stop-daemon --exec /tmp/test.sh --background --start I suppose will save the pid file somewhere and later use it for stop or restart, right? So ...
0
votes
1answer
43 views

SSH to last current location

Is there a way to make the default ssh location be the folder that was current when last logged out? I'm using bash and Ubuntu, so it looks like I could use the .bash_logout file to set a variable, ...
5
votes
1answer
2k views

Add server to known_hosts

I would like to add github.com to the known_hosts file from the command line as I am creating a puppet manifest to provision a remote server. I have tried: "ssh-keyscan -H github.com > ...
7
votes
4answers
23k views

How can I edit the welcome message when ssh start?

I have a vps for my website hosting. It is running a ubuntu server. Every time I logged in my server by ssh, it displays a lengthy welcome message in my terminal. Linux node61.buyvm.net ...
1
vote
1answer
288 views

Can't restart mysql from cron job

I have a problem where MySQL (running on Ubuntu 12.04 with all latest updates) dies after a few days so put this script into a cron job that runs as root every 60 seconds. Everything works except ...
2
votes
3answers
75 views

du displaying old results

I ran du -hs to find out how big my /home/user directory was and it reported as 18G. I cleared out almost 4G of data and ran du -hs again to find out how much space I actually saved and it still ...
5
votes
1answer
396 views

bash tab completion only works for root

I set up an Ubuntu 12 server (on rackspace cloud using their preconfigured image) and created a non-root user. When I log in as the standard user, pressing [TAB] at the terminal outputs an actual tab ...
1
vote
3answers
459 views

How can I automatically restart Apache and Varnish if can't fetch a file?

I need to restart Apache and Varnish and email some logs when the script can't fetch robots.txt but I am getting an error ./healthcheck: 43 [[: not found My server is Ubuntu 12.04 64-bit #!/bin/sh ...
1
vote
3answers
318 views

How to execute further commands in a Linux startup script after starting a process

I am trying to write a startup script that executes an application (MapProxy) after a server reboot. My server runs Ubuntu 11.04 Natty 64 bit. In the script, I execute a python script exec python ...
3
votes
1answer
165 views

Ubuntu freezes when I run “ps” or “top”

Ubuntu 11.10 Bind9 (not working, won't accept connections) (named-checkconf and named-checkzone both work) OpenVPN (community edition) (working correctly) (bridged mode) PHP5 & PHP5-gd Mysql5 ...