Tag Archive for unix

Crontab Info

#####################################################################
# field         allowed values
# -----         --------------
# minute        0-59
# hour          0-23
# day of month  1-31
# month         1-12 (or names, see below)
# day of week   0-7 (0 or 7 is Sun, or use names)
#
#
# (*) - stands for all
# (0-9) - range of numbers
# (0,4,6,9-11) - list of numbers and ranges
# (*/2) - step every X
#
# EXAMPLE:
#
# Every 5 minutes, of every hour, on the 2nd through the 10th and 20th
# through the 30th of the month regardless of the day of the week, run
# myscript.
#
# */5 * 2-10,20-30 * /bin/myscript
#
# To disable the email notifications you can either do it:
#
# Globally, add to the top of the Crontab
# MAILTO=""
#
# Per Command:
# [time] [command] >/dev/null 2>&1
#
#####################################################################

source

blipsend

#!/bin/bash
# simpliest blip client aka blipsend  - a very simple bash script by Łukasz Korecki, <a href="http://coffeesounds.com" >http://coffeesounds.com</a>
# put your blip login details (login:password) in ~/.blipdata file
# usage:
# TODO: support for char's like: ) / etc...
if [ -a ~/.blipdata ]; then
curl -H'User-Agent: blipsend 0.1' -H'Accept: application/json' -H'X-Blip-api: 0.02' -u $(more ~/.blipdata) -F "update[body]=$(echo $@ | sed 's/ / /g')" <a href="http://api.blip.pl/updates" >http://api.blip.pl/updates</a>
echo "Your message: $@, was sent"
else
echo "Missing ~./blipdata file! Put your credentials in login:password format in this file!!!!11"
fi

source

Use Unix ‘find’ to propset the svn Id on many files at once

# this affects already existing files
find app/lib/ -type f -name '*.js' -exec svn propset svn:keywords "Id" {}  ; -print

# OR, for files added later, you can edit ~/.subversion/config
[miscellany]
enable-auto-props = yes
[auto-props]
*.js = svn:keywords=Id

source

copy directory (unix)

cp -R /verzsource/ /target

source

unix timestamp to date

<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* Smarty convert to unix
*
* Type:     modifier
* Name:     convertunix
* Purpose:  convert unix timestamp to date
* @author   Frank Broersen
* @param string
* @return string
*/
function smarty_modifier_convertunix($sString,$sFormat)
{
return gmdate($sFormat, $sString);
}
?>

source

Preventing Apache memory leaks with ulimit

#!/bin/sh

HTTPD=/usr/local/apache2/bin/httpd
CONF=/bmi/httpd-php/conf/httpd.conf

exec 2>&1
echo starting...
ulimit -v 100000
exec $HTTPD -f $CONF -D NO_DETACH

source

Password Protect Folder / Directory with htaccess and htpasswd on Apache and Linux / Unix

Step 1 - Create .htaccess file in folder you want to protect, copy the code and paste the code below, and then set server path to the file

AuthUserFile /path/to/.htpasswd
AuthName "Restricted Area"
AuthType Basic
Require valid-user

Step 2 - Open Terminal, go to the directory you want to protect, and enter the following (changing the username to whatever you want). Enter the password upon prompting.

htpasswd -c .htpasswd username

source

fix permissions for files and directories

chmod -R u=rwX,go=rX .

source

Fill a disk with zeroes

dd if=/dev/zero of=/dev/hda/zero bs=512

source

Get the total disk space remaining

df -h

source