Archive

Archive for June, 2011

Crontab and vim – No syntax highlighting

June 30, 2011 2 comments

Problem:
crontab -e displays the cron jobs but there is no syntax highlighting. But .vimrc has syntax on. When I run vim otherfile.sh the syntax highlighting kicks in. So the issue was with the editor that crontab uses.

shell> man crontab

-e This option is used to edit the current crontab using the editor
specified by the VISUAL or EDITOR environment variables. After
you exit from the editor, the modified crontab will be installed
automatically.

Solution:
Check if the EDITOR variable is set to vim. If not, then that is where the problem is.

1. How to check?

shell> set | grep EDITOR

If it returns blank or points to a different editor apart from vim then change it. Note that by default if the variable is not set, it will use vi. And that might be why the syntax does not show. There are also stripped down versions of vim eg vim-tiny that does not have syntax highlighting. (Unfortunately, I was not able to discover what editor crontab used.)

shell> which vim
/usr/bin/vim
shell>EDITOR="/usr/bin/vim"
shell>export EDITOR
shell> set | grep EDITOR
EDITOR=/usr/bin/vim
_=EDITOR

That should set your Editor to be vi for that session only. If you log out and log in your changes will be lost.

Making your change permanent.
1. Add the following to ~/.bash_profile (For that particular user) or to /etc/profile (For all users).

EDITOR="/usr/bin/vim"
export EDITOR

Source
http://www.netadmintools.com/art395.html

NB. I had this problem on a Red Hat server.

Categories: bash Tags: ,

GMail – grouping email contacts

June 30, 2011 Leave a comment

Problem:
A colleague asked me how to create a group of contacts. What happens is that he sometimes needs to email a bunch of guys and he does get tired typing in the same email addresses 5 times a day.

Solution:
Group contacts. This has been explained very nicely in the Gmail Help.
http://mail.google.com/support/bin/answer.py?answer=30970
http://mail.google.com/support/bin/answer.py?answer=30971

Categories: mail

IRC – How to register your nick.

June 17, 2011 2 comments

Problem:
Was trying to join #django IRC on freenode but was getting this error. (using pidgin).

Cannot join #django: Registration is required.
Cannot join channel (+r) – you need to be identified with services

Solution:
Join any other room. Then type
/msg nickserv register [your-password] [your-email-address]
And email will be send to your address with instructions on how to register. eg
/msg NickServ VERIFY REGISTER [system-generated-password]

Once that is done. You can now join the desired chat.
/join #django

/quit will disconnect you.

If you log in again. You will get the following message.

(04:57:17 AM) NickServ: (notice) This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify .

Type
/msg NickServ identify [your-password]
You have to use the same password that you registered with. (Not the system generated one, the other one :-))

More info:
http://gallery.forgotten-beauty.com/Nickserv.html
http://freenode.net/faq.shtml

Laptop screen blank when switched on

June 16, 2011 Leave a comment

Problem:
Laptop screen is blank when I try to switch it on. I can feel the HDD spin, the LED lights up, the DVD drive spins and its LED lights up but the machine does not boot.

Solution:
Found the solution over here http://en.kioskea.net/forum/affich-24155-laptop-screen-blank-when-switched-on. The first tip worked for me.

… Unplug the power, remove the battery and then hold the power button for 30 to 60 seconds. Then reattach the power and attempt a boot… Just shutdown, put the battery back in you’re good to go…

This worked for the Toshiba Satellite Pro that I was using.

Moving thunderbird mail

June 15, 2011 Leave a comment

Problem:
Did a clean install of Linux Mint Debian edition on a laptop. Needed to restore the old emails on Thunderbird. The instructions below are what I did for a Linux to Linux move.

Solution:
1. Before formatting the machine. Backup the thunderbird folder. Locations may differ. Linux Mint Gloria uses /home/user/.mozilla-thunderbird/ while Linux Mint Debian Edition uses /home/user/.thunderbird
To know where your files are open thunderbird. Get to the Account Settings. Click on Server Settings. Look for the place that says Local Directory. That is where your files are. Make a note of that. Close thunderbird and copy the entire folder to a different computer.

shell> cp /home/user/.mozilla-thunderbird to /home/user/mozilla-thunderbird_old
shell>scp -r /home/user/mozilla-thunderbird_old user@remote_machine_ip:/home/remote_user/

2. Backup any other files you want to back up.

For the paranoid user.
Install ImportExport available here http://www.nic-nac-project.de/~kaosmos/mboximport-en.html. Use it to backup your thunderbird files. Save the files on a different machine.

3. Go ahead and format and install new system.

After new install.
1. Start Thunderbird and create a test account. Then find out the location of profile files by checking in Account Settings again. (Repeat step 1 above.)
2. Copy over the old mail folder.

shell>scp -r user@remote_ip:/mozilla-thunder_old .

3. Overwrite the new folder.

shell>mv mozilla-thunderbird_old /home/user/.thunderbird

4. Start up thunderbird. It should start off with the “old” account setting.

5. If that did not work then install ImportExport add on and use it to get the files you have previously backed up.

Categories: mail Tags:

bash – Add time and date to history log

June 13, 2011 Leave a comment

Problem:

Had a situation at work where it is *alleged* that a cron job ran twice. We checked the crontab logs in /var/log/messages but the said cron job was only recorded once. Looking at the bash history we noticed that the affected script was run on the command line, but unfortunately, we could not tell *when* it was run. Which forced us to add timestamps to the history file. If only we had done that earlier. Hopefully, this will be able to shed some light in case it happens again. Only down side to this is that the old commands in the history file get that days timestamp.

Solution:
Add the following line to your users .bash_profile or to .bashrc

export HISTTIMEFORMAT=’%Y-%m-%d %H:%M:%S ‘

shell> source .bash_profile

Before:

  152 history | less
  153 less .bashrc
  154 exit

After:

  155  2011-06-13 11:13:11 mount /dev/sda2
  156  2011-06-13 11:13:11 history | less
  157  2011-06-13 11:13:11 vim .bash_profile
  158  2011-06-13 11:13:11 source .bash_profile 
  159  2011-06-13 12:08:43 history | less
  160  2011-06-13 12:09:05 exit

Formats used:

%Y year
%m month (01..12)
%d day of month (e.g, 01)
%H hour (00..23)
%M minute (00..59)
%S second (00..60)

For other formats read man date

Categories: bash Tags: , ,

Icedove – Error: [Exception… “update.locale file doesn’t exist

June 13, 2011 Leave a comment

Problem:
I had the following error in my icedove error console.

Error: [Exception… “update.locale file doesn’t exist in either the XCurProcD or GreD directories” nsresult: “0x80520012 (NS_ERROR_FILE_NOT_FOUND)” location: “JS frame :: file:///usr/lib/icedove/components/nsUpdateService.js :: getLocale :: line 608” data: no]
Source File: file:///usr/lib/icedove/components/nsUpdateService.js
Line: 608

Solution:
Followed the instructions here. http://www.linuxplanet.org/blogs/?cat=4051

touch /usr/lib/icedove/update.locale

The error went away. Will keep monitoring though.

Update:
The error has not come back. Icedove works like a charm. So I guess the “fix” worked.

Categories: mail Tags:

Error 2006: MySQL Server has gone away.

June 8, 2011 Leave a comment

Problem: Getting this error in my python script

Traceback (most recent call last):
File “my_application.py”, line 202, in
main()
File “my_application.py”, line 186, in main
traceback.format_exec())
AttributeError: ‘module’ object has no attribute ‘format_exec’

When I check my application logs I have

OperationalError: (2006, ‘MySQL server has gone away’)

Solution:

Increase the wait_timeout value in /etc/mysql/my.cnf.
In my case I changed it from 6 to 600

wait_timeout = 600

As root restart the mysql server. /etc/init.d/mysql restart

More information on this error (for mysql 5.0) can be found here. http://dev.mysql.com/doc/refman/5.0/en/gone-away.html