Browsing articles tagged with "shell - Admins Goodies"
Mar 16, 2013
tom

How to synchronize command calls on Linux

This is my specific problem I need to solve (But my question is different, so please read on even if you don’t know what fail2ban is): I’m trying to use fail2ban on a linux server to ban brute force attacks on multiple services (ssh, dovecot, apache, postfix, …). Now I stumbled over the problem that fail2ban seems to execute multiple iptables commands at the same time (with threads in Python) and this fails pretty often [...]

Continue Reading »
Feb 3, 2013
tom

Adding a timestamp to bash script log

I have a constantly running script that I output to a log file: script.sh >> /var/log/logfile I’d like to add a timestamp before each line that is appended to the log. Like: Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph. Is there any jujitsu I can use? Asked by Antonius Bloch You can pipe the script’s output through a loop that prefixes the current date and time: ./script.sh | while IFS= [...]

Continue Reading »
Jan 9, 2013
tom

Cannot change chmod from bash script

I made a script to copy an image to a temporary directory, convert it to an another format, then move it to a final directory. But i can’t get the chmod command to work, the file is copied to the temporary directory but it’s chmod is stuck on -rw——- (the original chmod of the file). If i apply a 777 chmod on the original file, the copied one get a -rwx—— instead of a -rwxrwxrwx [...]

Continue Reading »
Dec 12, 2012
tom

Daemon process exiting when shell closes

I have a script which starts a daemon process and then sleeps for 20 seconds. If I run the script on SLES11 SP1 or RHEL6 then after the script exits the process is still running. If I run the script on SLES11 SP3 or RHEL6.3 then after the script exits the process is no longer running. The process continues to run for the entire 20 second sleep and is killed when the process exits. The [...]

Continue Reading »
Dec 12, 2012
tom

What shell script is calling rsync?

For the last couple of days, I’ve woken up to find rsync churning away with 1.6GB of memory, slowing my Mac down significantly. Activity Monitor only says that rsync is coming from sh, but I’m trying to track down more info; specifically, what shell script is calling rsync. How can I find that out? Asked by Rob D. It’s simple. Use the ps command to check the parent of the rsync process, something like this. [...]

Continue Reading »
Nov 18, 2012
tom

run php script in the background

is there a way to launch a php script and let it run on the server until it finishes? I use this php5-cgi /var/www/script.php -q & connecting via putty. When I close it (the session) the script stops! Why does it run dependent on the session? Asked by Sandro Antonucci Try nohup and disown: nohup php5-cgi /var/www/script.php -q & disown Answered by Dennis Kaarsemaker Check more discussion of this question. Bookmark on Delicious Digg this [...]

Continue Reading »
Oct 28, 2012
tom

date and other commands no longer working in sh script

I have a shell script that used to run find on Ubuntu 10.04 but since I have moved to 12.04 it doesn’t work as before throwing the following messages: /home/checks.sh: 1: /home/checks.sh: date : not found find: invalid mode `0777\r’ the script is as follows: date echo “” echo “Files changed in the last 24 hours” echo “==================================” find /var/www -mtime -1 | grep -iv ‘.log’ echo “” echo “” echo “Files with permissions set [...]

Continue Reading »
Oct 20, 2012
tom

Script to run chown on all folders and setting the owner as the folder name minus the trailing /

Some numpty ran chown -R username. in the /home folder on our webserver thinking he was in the desired folder. Needless to say the server is throwing a lot of wobbelys. We have over 200 websites and I don’t want to chown them all individually so I’m trying to make a script that will change the owner of all the folders to the folder name, without the trailing /. This is all I have so [...]

Continue Reading »
Sep 23, 2012
tom

df -h overreports disk space on VPS

When I run the command df -h on my new Ubuntu linux vServer I get the following: # df -h Filesystem Size Used Avail Use% Mounted on /dev/hdv1 466G 33G 434G 7% / none 16M 0 16M 0% /tmp Running du -sh gives # du -sh du: cannot access `./proc/13624/task/13624/fd/4′: No such file or directory du: cannot access `./proc/13624/task/13624/fdinfo/4′: No such file or directory du: cannot access `./proc/13624/fd/4′: No such file or directory du: cannot [...]

Continue Reading »
Sep 19, 2012
tom

Confusion over terminology SSH, Shell, Terminal, Command Prompt and Telnet

I don’t usually use SSH if I can get away with it, but if I have to I do of course, and I’ve seemingly done this for years while still managing to remain slightly confused about these different terms … from my basic research, this is my understanding, could someone verify/correct this? Telnet … before SSH, not secure SSH … ( secure shell ) the general name of the system/protocol Shell … short name for [...]

Continue Reading »
Pages:1234567...39»