1
vote
2answers
27 views

Kill all currently running cron jobs

For some reason my cron job scripts aren't exiting cleanly and they're backing up my server. There are currently a couple hundred processes running for one of my users. I can use the following command ...
0
votes
0answers
14 views

Disabling ssid broadcast programatically/CLI and keeping exsisting devices connected DD-wrt access point [closed]

I'm trying to disable/hide my SSID broadcast programatically in order to stop devices connecting to my access point (not for security reasons). I have tried renaming the SSID and setting it to nothing ...
0
votes
0answers
24 views

Odd behaviour with varnishlog and stream redirecting

I wrote a helper to debug varnish installation and have used it on both production and development server. The odd thing is, I encountered different behaviour even though the setup is nearly identical ...
0
votes
3answers
84 views

Tail a file from ssh and mirror to a local file

To tail a file over ssh, I can use ssh -t remotebox "tail -f /var/log/remote.log" However, it is possible to sync the tail with a local file? So a file automatically mirror the update of the tail ...
1
vote
1answer
416 views

Fork a process inside a bash shell script

I've a simple shell script like #!/bin/bash sh -c "sleep 60" & exec sleep 120 In using the pstree command, I found something like `-sleep(11681)---sleep(11682) The first sleep is due to the ...
1
vote
2answers
53 views

Rsync plugin to many local wordpress installs via script or cli

I am maintaining a large number of wordpress installs on a production server, and we are looking to deploy InfiniteWP for managing these installs. I am looking for a way to script the distribution of ...
1
vote
2answers
120 views

How to split a file and compress directly?

I've a 100GB file and I want to split into 100 of 1GB file each (by line break) e.g. split --bytes=1024M /path/to/input /path/to/output For the 100 files generated, I want to apply gzip/zip to ...
1
vote
1answer
61 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
223 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
90 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
70 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 ...
-1
votes
2answers
58 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 ....
2
votes
3answers
215 views

how to convert a running process into a nohup and keep a logfile

I have a process currently occupying a terminal ]$ command some_argument I want to exit from the terminal and go home, but in the mean time I don't want to kill this running process. For the ...
0
votes
1answer
31 views

Why is Cat quoting individual words in command substitution

All, I'm attempting to use command substitution to keep command line arguments in a file. My initial thought was to simply place the command line arguments in a single line in a file and then call ...
-1
votes
2answers
150 views

Cannot source .bashrc over SSH

Logging into my work station over SSH, I notice that none of my aliases work. Sure enough: $ alias $ source ~/.bashrc Could not open a connection to your authentication agent. So I googled the ...
1
vote
3answers
208 views

How to stop bare bash cd (change directory command) from changing the working directory to $HOME?

I do this too often: $ pwd /a/long/long/way/from/anywhere $ cd # oops - meant to tab-complete something /home/$USER Can cd defaulting to $HOME be disabled?
12
votes
2answers
532 views

backslash at the beginning of a command

In Installing RVM manual I see a lot of lines starting with '\': Install RVM with ruby: $ \curl -L https://get.rvm.io | bash -s stable --ruby I'd think it is just mistype but they repeat ...
0
votes
2answers
480 views

special characters in http_proxy environment variable

What is the correct format using special characters in http_proxy environment variable? Or to be mor specific, what to do with special characters in username or password when authenticate to http ...
-3
votes
3answers
2k views

How to find files of certain extension and tar each of them in to another location

I have script for finding files of certain type and compress them to a single tar archive and put in to other place. But now, there is a change in requirement, that I need to find files of certain ...
0
votes
1answer
181 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 ...
3
votes
2answers
157 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 ...
0
votes
3answers
234 views

Files copying between servers by creation time

My bash scripting knowledge is very weak that's why I'm asking help here. What is the most effective bash script according to performance to find and copy files from one LINUX server to another using ...
0
votes
2answers
633 views

how to check how many minutes have passed since the user is idle? [closed]

I want to write a script that will show how many minutes the user is idle. Since the last touch of the keyboard and mouse. Example: #!/bin/bash while true do command_lines... ... sleep 60 echo ...
2
votes
1answer
117 views

Unix Command to timestamp the output of a file, but with the relative-to-when-it-started time?

There are numerous programmes (e.g. ts in moreutils), and various bash one-liners to prepend the output of a command/pipe with the timestamp of when that line was 'printed'. However is there a ...
10
votes
4answers
519 views

How would you simplify this command?

I'm quite new to strace / netstat / etc. I'm using this command to get a trace of the apache process handling my request (telnet), is there a way to simplify it a bit? sudo strace -o /tmp/strace -f ...
1
vote
1answer
2k views

pgrep/pidof usage for complex process names?

I am trying to use pidof or pgrep to be able to send a HUP to a process in my system. The problem is that I only want to kill the process with a precise parameter. This is the output of 'ps awx' ...
1
vote
4answers
459 views

Concatenate variable in string bash

I want to kill a process in specified port (variable) export PORT=3030 netstat -ntlp | awk '$4~/:*${PORT}$/{gsub(/\/.*/,"",$NF);cmd="kill -9 "$NF;system(cmd)}' but variable PORT doesn't get in the ...
3
votes
2answers
610 views

sudo -i but keep current working directory

When use sudo -i I will simulate login as root, and current working directory will be jumped to /root. Is it possible not to jump and keep the working directory unchanged?
0
votes
1answer
161 views

mysqldump asking for password even after telling it the password in the command line option

I am using the following command: mysqldump -alv -h 123.123.123.123 --password=P@ssw0rd --user=UsernameHere --add-drop-table -p DatabaseSchemaName > dump.sql Then it asks me to Enter Password. ...
1
vote
2answers
245 views

Bash Command Line In-Line Array

Any bash gurus know how to turn the commands below into a one liner? trutch:$ touch app/views/pages/_sponsors.html.erb trutch:$ touch app/views/pages/_donations.html.erb trutch:$ touch ...
13
votes
2answers
2k views

What is the difference between sudo -i and sudo su -

What is the difference between commands sudo -i and sudo su -? Are they the same?
2
votes
2answers
2k views

Sending mail from command line if body not empty

I'd like to write a simple script that alerts me if a log changes. For this I'm using grep to find the lines I'm interested in. Right now it works like this: grep line /var/log/file | mail -s Log ...
0
votes
4answers
431 views

“Command not found”-unable to run the bash script [duplicate]

Possible Duplicate: My cron tasks report command not found I am trying to run a bash script #!/bin/bash export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com # get ec2 instance id ...
2
votes
2answers
523 views

BASH: Newline or HR after long command output

Is there any way to configure Bash to print a newline or horizontal line after commands that provided more than N lines of output? For instance, after a simple cd I don't need a newline or horizontal ...
2
votes
1answer
258 views

What does the leading dash in process cmdline mean?

I noticed a process taking full CPU on my linux server, of which the COMMAND column from top -c is -bash. cat /proc/<pid>/cmdline shows -bash too. What does the leading dash mean? More info: ...
13
votes
3answers
1k views

Strange bash history behaviour when running multiple sessions

How is command line history stored when I use multiple terminal windows? I know it is stored in .bash_history but I can't see the logic on what history is used if I open new window. It almost feels ...
88
votes
24answers
26k views

How do I prevent accidental rm -rf /*?

I just ran rm -rf /* accidentally, but I meant rm -rf ./* (notice the star after the slash). alias rm='rm -i' and --preserve-root by default didn't save me, so are there any automatic safeguards for ...
1
vote
1answer
785 views

Can't change path location of PHP on mac os x snow leopard

I have XAMPP installed on my mac, and I want to make command line PHP use the same executable as XAMPP since I've customized that php's php.ini file. The php binary I want is located at: ...
1
vote
4answers
866 views

Cannot remove or list directory (ls or rm) Linux - Debian

I have a log file directory at /var/log/apache2/vhosts on a Debian dedicated server. Every day I split the main access_log into respective vhostname.com_access_log files in /var/log/apache2/vhosts In ...
0
votes
1answer
102 views

bash script parameters & error trapping

I've created a bash script for a cron job that I'm using to convert an uploaded file to a couple of formats and then moving it to another folder where another cron job will store it away, etc. The ...
1
vote
2answers
146 views

How do I execute a sequence of commands by writing one line in bash? [closed]

With cmd.exe's interpreter this is easy: echo testline > .\test.txt && c:\windows\system32\notepad.exe .\test.txt What is the equivelent to this with bash? For instance, vim doesn't ...
1
vote
3answers
128 views

Run another command if there is any input on the standard input

How can I run another command if there is any input on the standard input commonly used in situations like this: some command with no normal output | ifinput mail -s 'some output' me
2
votes
4answers
2k views

prevent xargs from quitting on error

According to the man page, xargs will quit if one of the execution lines exits with an error of 255: If any invocation of the command exits with a status of 255, xargs will stop immediately ...
1
vote
1answer
2k views

Pass password to adduser command

Just wondering if it's possible to pass the password I want to use to the adduser command in ubuntu, so that it can be automated. I want to do something like this echo "password" | adduser test ...
-1
votes
2answers
2k views

Bash ping successful program

I'm thinking that this needs to be changed to a while loop because, at the moment, it'll wait untill all 10000 pings are done. I need this to return when the ping is successful. What are your ...
1
vote
3answers
400 views

how i can get the date in UNIX-aix and store ecah part in variable

I write batch file and i want to compare the modification time (timstap) to two folder and copy the latest one . i don't know if this option available directory be cause i don't know .so i want to get ...
3
votes
2answers
242 views

Command Line One-Liners: Quick & Dirty “Bytes Transferred” report

Alright. So we have a lighttpd server pumping out the loading of our images. It logs on a daily basis, and we're considering moving all those images to our S3 account for better load times, but ...
7
votes
3answers
389 views

Keyboard shortcut to store typed command and clean the line

You know the situation: You are halfway through typing a long command (for example a commit message) and realize that you have forgotten to execute some prerequisite command that can not be added with ...
2
votes
3answers
948 views

Use SSH to execute remote export command and stay logged in

I have a simple problem of needing to execute an export command over ssh, and then stay logged in, but I'm having some trouble. Though I am interested in a solution to this problem for many reasons, ...
1
vote
2answers
358 views

what does the command bash do when typed in a linux terminal? [closed]

When I type bash in to linux cli, it gives me bash-3.2$ so what does it do?