The shell-scripting tag has no wiki summary.
1
vote
1answer
35 views
Cronjobs putting archive in wrong directory
I am running a website on an Amazon ec2 instance running the default Debian linux. I set up a cronjob to copy the site files, take a database imprint, and zip them up. I want to keep the file ...
2
votes
1answer
33 views
Hold till last command completes its execution
I am developing a shell script which actually stops aws running instances in a particular region & start them again as a part of schedule maintenance. but as ec2-api tools are heavy, takes time to ...
-1
votes
2answers
52 views
Shell script :: Reading a column from file & store it in array [on hold]
I am working on shell script where i want to store O/P of the command in array.
I have a file containing rows & columns from where i want to extract 3rd column & store all values in a array. ...
1
vote
5answers
55 views
linux how to tell the process for a script?
I ran a script postData.sh, but when I do "ps -ef", I don't see the script in the list of programs running but I do see extra -bash processes running. How do I determine the pid so I can kill the ...
0
votes
0answers
37 views
How to find files by the time in their filename? [migrated]
We have a directory contains files which contains time in their filename
./test.2013-06-11_06-01.gz
./test.2013-06-12_01-01.gz
./test.2013-06-13_03-01.gz
./test.2013-06-14_03-01.gz
...
0
votes
1answer
39 views
Nagios: bash is missing
I'm monitoring NTP server with nagios and nrpe, at the nagios server, when I get the following error:
Service Status UNKNOWN
Status information I am missing an important component : bash
The plugin ...
0
votes
0answers
19 views
Create .tar.gz from a directory ommiting some subdirectories and add only files with changes or newest? [migrated]
I'm not a Linux expert but because I do this task several times in a day so I think to build something for do this job. So as the title said I need to create a script, maybe bash, maybe just a .sh ...
1
vote
1answer
40 views
How do I find the biggest files on multiple servers and sum up their size?
I am trying to find the biggest files in the /export/home directory and add up (sum) their sizes.
Script:
#!/bin/bash
filename=hostnames
> export_home.log
while read -r -a line
do
...
1
vote
1answer
55 views
Automatic provisioning of Windows server from a Linux client.
Our company builds a server-based C++ application, which can be installed by a Windows installer.
I would like to be able to remotely log into a brand new Windows server, and install that C++ ...
1
vote
1answer
26 views
nice command - are other commands executed with script also niced?
A quick question about how nice works.
Say if I have a script that runs in the crontab like so
0 4 * * * nice -n 19 /usr/local/admin/script.pl
It is set to the lowest priority. This script will ...
0
votes
0answers
39 views
using find, exec, sed to manipulate strings as args to another program [migrated]
I can use find like this
find -type f -path "./src*" -name "*.php"
to find a list of files.
For example ./src/Superuseradmin/Model/Mapper/UUID.php
What I need to do is manipulate each string in the ...
-1
votes
1answer
33 views
Bulk BIND zones creation [closed]
How can I create zones for 50 domains on Ubuntu 12 VPS? I have webmin (which allows me to use BIND to create/ manage zones). I was able to figure out what gets created to add a zone successfully.
But ...
0
votes
1answer
30 views
Solution to start/stop many instances of one application
I have one tool that performs a long-running task. This tool accepts a configuration file. Right now I need to run simultaneously about 15 instances with different configs (using screen for this).
...
0
votes
2answers
47 views
linux + how to identify if file is pointed by link/s
I create new file called - 192.9.200.1
touch 192.9.200.1
then I create new link that will be pointed to 192.9.200.1 file
ln -s 192.9.200.1 file
so finally I get:
ls -ltr /tmp
...
0
votes
3answers
84 views
Connect to cisco switch using shell script
I would like to run a daily script the cleans my switch arp.
I enabled SSH on my switch.
how do I connect to the switch using a simple shell script?
I'm not sure how to provide the SSH password and ...
0
votes
2answers
51 views
linux + delete duplicate IP's from file
what the best way to remove duplicate IP's from file
I use the command:
sort file | uniq
but I am not sure if this is the best way , maybe I missed something?
remark: my file contain two ...
0
votes
1answer
32 views
Hudson kills the process at end of the shell script
Im configuring Hudson to automate deployment process. In shell script I start the server using different user and Im able to see the logs which says server is successfully started and able to access ...
1
vote
2answers
61 views
What is this specific shell script statement validating?
I'm not a good Shell Script expert. Can somebody help me to understand and explain the statement [ ! -z ${TRUE:-} ] && [ ${TRUE:-} == 'true' ] &&from the following snippet. What is ...
-1
votes
1answer
35 views
Can not seem to get expr substr to work
Can anyone tell me what I am doing wrong ?
[ /jlr/sub/libexec/vmr-staging ] $ expr substr "onetwothree" 1 4
expr: syntax error
I got the syntax from http://stackoverflow.com/a/220464/1150847
4
votes
2answers
158 views
supress expansion of * in echo
I am working on a script which dynamically executes some queries on daily basis. These queries are coming from a table in the database.
Here is the sample output of the query table:
...
0
votes
1answer
51 views
Recursively delete empty folders with verbose output
This should be fairly simple, but I am not sure what i'm missing.
I'd like to recursively delete empty directories, and get an output for what's being deleted, this command works for sure, but I just ...
1
vote
3answers
126 views
In zsh, how do you redirect stderr to /dev/null within a for or foreach loop?
I am trying to accomplish something that is easy in bash: look for files in a folder and source them if they exist (and do not output if no files exist).
In bourne shells this is how to do it:
if ...
0
votes
0answers
32 views
Get Rsync status for output
At the end of a successful rsync job, I get the typical:
sent 6022622 bytes received 4751961 bytes 69738.40 bytes/sec
total size is 3328464484 speedup is 308.92
I call my rsync job via a shell ...
0
votes
1answer
72 views
Bash: php comand not found when called from a script run with sudo
I have this weird problem. The php command is not found in one specific sitiation.
I try to call the command in three different ways. Only one of them fails:
Being user john I create a simple ...
-1
votes
1answer
60 views
run expect script from other shell [closed]
my target is to create the /var/tmp/add_user.bash script by /var/tmp/create_script_add_user.bash script
and run the expect script ( add_user.bash ) from create_script_add_user.bash script
the ...
1
vote
2answers
25 views
script reading from new descriptor in read
I have a script that asks some questions to the user and repeats the question until the user has answered something appropiate. This is done with an infinite loop that is break'd when an acceptable ...
0
votes
1answer
56 views
can't access sourced variables inside Upstart script stanzas
I'm trying to use the variables defined in /etc/environment in an upstart script.
I'm able to export the variable to the child process but for some reason I not able to use them in the upstart script ...
0
votes
2answers
92 views
re-create new link and remove the old link on one command
according to ln manual page:
man ln
-f, --force
remove existing destination files
so as I understand if I want to re-create new link to some destination directory/file
I can ...
0
votes
0answers
91 views
How to get range time a log file in shell script
How to get range time using awk command?
I have two variables $from and $to with format (hh:mm:ss)
I want to get the range time between two variables.
For example: get all range time between:
...
0
votes
4answers
95 views
How to automatically clean up date stamped logs
I have an apache web server with various virtual hosts. Each virtual host logs to date stamped files using cronolog. The result is that I end up with a lot of files like this:
----rw-r-- 1 root ...
0
votes
2answers
133 views
FreeBSD rc.d scripts do not return to proper shell
My interesting problem is that when running some rc.d scripts they do not actually drop back to the root shell, but leave me at an intermediate shell as the user they're supposed to be running as.
A ...
1
vote
2answers
217 views
shell script in crontab, not all output being logged
I've got a simple shell script that runs a few LFTP commands and processes the files.
When running straight from bash I get full output of those LFTP commands on screen.
When running from crontab ...
-2
votes
1answer
59 views
case + how to implement equal or less or greater in case syntax
my target is to verify the range of number with (only with - case + esac ) , and print the range
so for example
if number is between 0-80 , case will print
>=0<=80
or if range is ...
0
votes
3answers
47 views
Finding the file/script that invoked a process
I do have a high CPU utilization PhP Process. This process in turn seem to invoke mysql and
both processes together are using all the CPU cores and RAM
using
ps aux | grep php , i could get the ...
1
vote
1answer
123 views
Mysql incremental backup and point in time recovery
I have a requirement for doing Incremental backup of MySQL database. For which I'm writing a shell script using the concept of binary logs.
Now, the scenario is such that a full-backup will happen ...
-1
votes
1answer
34 views
running script containing sudo in cron [duplicate]
#!/bin/bash
value=$(<man.txt)
echo "$value"
if [ "$value" == "true" ]; then
echo "startedif_manthan"
ps -ef|grep sym |awk '{ print $2 }'|sudo xargs kill -9;
sleep 30;
sudo sh ...
-1
votes
3answers
60 views
Cannot start a script
#!/bin/bash
value=$(<man.txt)
echo "$value"
if [ "$value" == "true" ]; then
echo "startedif_manthan"
ps -ef|grep sym |awk '{ print $2 }'|sudo xargs kill -9;
sleep 30;
sudo sh ...
-1
votes
1answer
37 views
Different behavior from ubuntu server and ubuntu client on windows [closed]
#!/bin/bash
# Reading
cat /home/radiare/Desktop/first.txt | while read LINE
do
if [ "$LINE" == "false" ]; then
echo "Inside first loop"
break
fi
done
cat /home/radiare/Desktop/second.txt | while ...
-3
votes
2answers
66 views
perl one liners + add empty line after the last line [closed]
please advice
what need to change in the perl syntax in order to add new empty line after the last line?
example
IP_INFO=12.23.2.1
echo IP= | perl -pe "s/$/$IP_INFO/" 1>>file
.
...
1
vote
4answers
52 views
Howto: command/tool ability check
When developing a shell script that should run on various unix/linux derivates, i sometimes have the problem that some tools have to be called in a different way compared to other systems. For example ...
0
votes
1answer
50 views
ZSH escaping / file matching pattern
This works from command line:
scp -r ^.git b:/home/wopi/blyzics/.
when I paste the above line in a script like this:
#!/usr/bin/env zsh
scp -r ^.git b:/home/wopi/blyzics/.
And run it
...
0
votes
1answer
123 views
ssh tunnel and rdesktop in one line
To access a windows machine remotely I have to tunnel through a ubuntu server of mine. To setup the tunnel I have
ssh -l root -C -L 9999:windowsmachine:23389 myserver
Then I have to open another ...
-1
votes
3answers
151 views
Script to restart httpd if crashed
With heavy trafic, it happen that's my HTTP service crash on my dedicated server. Then, I have to restart httpd service manually.
I just search for a shell script that's detect if HTTP service is OK ...
1
vote
1answer
64 views
escaping spaces in shell script
yesterday="2010-06-23 00:00:00"
today="2010-06-24 00:00:00"
mywhere="lastupdate>'$yesterday' and lastupdate<'$today'"
mysqldump $param ticket --no-create-info --where=\"$mywhere\"
The last ...
0
votes
3answers
822 views
how to run shell commands from apache (through php )
I'm using redhat 6
I have the following shell commands that I need to run from the webserver (apache -> through php ) that basically move & overwrite a file , kill a process and starts another ...
3
votes
1answer
125 views
echo $? doesn't work when executed remotely
When I execute a command as below it gives me an output as expected but when I run the same command on remote server it always gives me echo $? as 0.
locally
# <some command>
# echo $?
...
8
votes
3answers
2k views
How do I sleep for a millisecond in bash or ksh
sleep is very popular command and we can start sleep from 1 second
# wait one second please
sleep 1
but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ...
0
votes
1answer
126 views
Using NFS mount script with grandfather father-son script but only getting 6 daily backups. I should also have 4 weekly and 2 monthly backups
I'm using rsync to clone changes from a remote server(MT DV4.0) to a local one(ubuntu 11.10). I'm then using the following copy/paste script to compress then archive the files.
#!/bin/bash
...
0
votes
2answers
101 views
Issues in Play framework Server when I start using su deploy -c “play start”
I have play framework server and Im doing Automation using Hudson,
When I start the play server using su deploy -c "play start" it's fine the logs are getting updated and server is started.
The same ...
0
votes
1answer
97 views
How to combine outputs of ps and lsof
Usually output of ps has a pid somewhere. Is there a way to combine this, preferably with a one-liner, with an output of lsof ?
e.g.
27915 ? Ss 0:03 gpg-agent --daemon
gpg-agent 27915 ...