Category Archives: LINUX

Formatting a Hard Disk on Ubuntu Server

Syntax:

umount filesystem
mkfs -t ext3 filesystem
mount filesystem

Example:
umount xvdp1
mkfs -t ext3 /dev/xvdp1
mount /dev/xvdp1

Advertisements

Increasing number of threads per process

There is no direct limit on number of threads a process can have. Rather, this is calculated using following formula:

number of threads = total virtual memory / (stack size*1024*1024)

Thus, the number of threads per process can by increasing total virtual memory or by decreasing stack size. Decreasing stack size can lead to code failure due to stack overflow while max virtual memory is equal to the swap memory.

Check you machine:

Total Virtual Memory: ulimit -v (default isĀ unlimited, thus you need to increase swap memory to increase this)

Total Stack Size: ulimit -s (default is 8Mb)

Command to increase these values:

ulimit -s newvalue

ulimit -v newvalue

replace new value with the value you want to put as limit.

How to increase swap memory?

http://www.ehow.com/how_5001512_increase-virtual-memory-linux.html

Tagged , , , , , , , , , , , , , , ,

Shell Script to find a process using grep and taking an accortion accordingly using if else

x=start.sh
y=`ps -ef | grep start.sh | awk '{print $9}' |head -1`
if [ $y = $x ]
then
	mail -s "SUCCESS: Fetcher Hourly Check" utsav.sabharwal@nextag.com,jyadav@nextag.com -a ""<<< "Hie Team,

This is to inform you that start.sh is running smoothly. So just sit back and chill.. .

I would recheck after one hour.

Best Regards,
Unix Script
etc/cron.hourly/mycron.sh
BETA Fetcher"

else
	mail -s "FAILURE: Fetcher Hourly Check" utsav.sabharwal@nextag.com,jyadav@nextag.com -a ""<<< "Hie Team,

This is to inform you that start.sh is not running on BETA URLBroker. Take appropriate action asap.

Please note, that I have been designed to update you guys every hour if I don't find a paster process running on my machine.

Best Regards,
Unix Script
/mycron.sh
BETA Fetcher"

Email via UNIX Command

Command:

mail -s “subject” to-email@id.com -a “Reply-To” <<“Your Message”

Note:

Press enter to change line, ‘\n’
etc wont work

Example:

mail -s “URLBroker Process Failure” utsav.sabharwal@nextag.com,jyadav@nextag.com -a “”<<< “Hie Team”

Tagged , , , , ,

Writing a Cron Job

Open Cron:

crontab -e

0 * * * * * filename <– command for hourly run update

Note:

Make sure file is executable

chmod 0755

.sh file does define which application to use to open this file.

#!/bin/bash <– add this line to top of your .sh code

Tagged , , , , ,