11/27/2007

for loop in DOS

http://www.computerhope.com/forhlp.htm

for /L %i in (1,1,100) do wget -w 5 -O %i.jpg "url"
for %i in (*.foo) do move %i %~ni.bar

11/20/2007

How to loop an array in bash

ids=(3333 3334 3335)
for id in ${ids[@]}
do
echo $id
done

11/13/2007

Auto start PostgreSQL when Linux boots (Ubuntu)



*as root*:
- Configure the PostgreSQL SysV Script. This script is useful for
starting, stopping, and checking the status of PostgreSQL.

# cd /usr/local/src/postgresql-7.x
# cp contrib/start-scripts/linux /etc/init.d/postgres
# chmod 755 /etc/init.d/postgresql
.... then edit the file to specify the data directory, etc. and sets the
environment variabes (PGDATA etc). The file is well documented. If you
installed Postgres manually, it should have the correct values already set.

- To have PostgreSQL start automatically when the computer boots add
symbolic links from the correct /etc/rc*.d/ directories to
/etc/init.d/postgresql.

ln -s /etc/init.d/postgresql /etc/rc0.d/K27postgresql
ln -s /etc/init.d/postgresql /etc/rc1.d/K27postgresql
ln -s /etc/init.d/postgresql /etc/rc2.d/S85postgresql
ln -s /etc/init.d/postgresql /etc/rc3.d/S85postgresql
ln -s /etc/init.d/postgresql /etc/rc4.d/S85postgresql
ln -s /etc/init.d/postgresql /etc/rc5.d/S85postgresql

etc ...

- Start PostgreSQL for the first time:

# /etc/init.d/postgres start

<\start>

Auto start PostgreSQL when Linux boots

*as root*:
- Configure the PostgreSQL SysV Script. This script is useful for starting, stopping, and checking the status of PostgreSQL.

# cd /usr/local/src/postgresql-7.x
# cp contrib/start-scripts/linux /etc/init.d/postgres
# chmod 755 /etc/init.d/postgres
.... then edit the file to specify the data directory, etc. and sets the environment variabes (PGDATA etc). The file is well documented. If you installed Postgres manually, it should have the correct values already set.

- To have PostgreSQL start automatically when the computer boots add symbolic links from the correct /etc/rc*.d/ directories to /etc/init.d/postgres. If the normal runlevel is 3 then you really only need to add it to rc3.d:

# ln -s /etc/init.d/postgres /etc/rc2.d/S85postgres
# ln -s /etc/init.d/postgres /etc/rc3.d/S85postgres

etc ...

- Start PostgreSQL for the first time:

# /etc/init.d/postgres start