Crontab and ~/.vimrc samples.

Posted: June 24, 2011. At: 10:22 AM. This was 6 years ago. Post ID: 1676

Well, I am coding an ad rotation script in PHP for my website that will be able to display a pseudo-random advertisement out of a choice that I have put into it, this will help me if I want to display something different in the same place, I can just display a random advertisement and this will work very well indeed. I am working on my index.php at the moment and tweaking the design even further to enhance the user experience as well as removing old and broken links. The problem with my user`s E-Mails I wrote about in my last posting was due to the fact that their E-Mail address was on a blocked list, so they might have been spammers. That is the best explanation for that situation in my opinion. I have good spam protection on my E-Mail account and most spam is automatically deleted, which works better than my other E-Mail account does, *cough* `Gmail’ *cough*. And Horde is the best E-Mail client for reading web mail. Now that I have tested my website in Internet Explorer 8.0, I am happy I do not have to use that again, and Windows XP, that is truly terrible. Below is the contents of my personal crontab file that has two commands that act as an alarm clock to wake me up in the morning. If you type crontab -e and type in these two lines, then your home PC can be an alarm clock as well!

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
 
30 8 * * * mplayer "/home/homer/sun.mp3"
 
40 8 * * * mplayer "/home/homer/sun.mp3"

This code runs this command at 8:30 AM, and again at 8:40 AM. This is a very easy way to run any command on your system when you want. It is a very powerful tool on a UNIX system and can automate so many things. And I have included below my ~/.vimrc that I use to edit text files on my Linux system. I prefer VIM over Emacs, which has a whole Cult/Church built around it, but it is difficult and convoluted to set up and configure just right compared to VIM. Getting K&R mode just right is very difficult indeed. I like using Emacs on FreeBSD though, and the ee editor is also a good one to use when you are setting up your system and editing /etc/rc.conf many times to configure your USB mouse and sound. Using VIM, if you want to edit a text file at line #1234, type vim myfile.txt +1234 and it will open the file at that line number. That is very useful when you are editing source code trying to get a program to compile. I am not sure if GNU Emacs can do this, but maybe someone could code a Lisp script for that editor that would be able to manage the same thing. Setting up a text editor should be an easy thing, but it turns out to be equal to the epic journey in the Lord of the Rings in terms of the convoluted journey you take through the Emacs configuration screen. And if you download a .emacs file off the Internet, it will not work because there is a Lisp module missing that it needs. Grr! :(. It should be easier to set up Emacs, but it is not.

" ~/.vimrc (configuration file for vim only)
" skeletons
function! SKEL_spec()
0r /usr/share/vim/current/skeletons/skeleton.spec
language time en_US
if $USER != ''
let login = $USER
elseif $LOGNAME != ''
let login = $LOGNAME
else
let login = 'unknown'
endif
let newline = stridx(login, "\n")
if newline != -1
let login = strpart(login, 0, newline)
endif
if $HOSTNAME != ''
let hostname = $HOSTNAME
else
let hostname = system('hostname -f')
if v:shell_error
let hostname = 'localhost'
endif
endif
let newline = stridx(hostname, "\n")
if newline != -1
let hostname = strpart(hostname, 0, newline)
endif
exe "%s/specRPM_CREATION_DATE/" . strftime("%a\ %b\ %d\ %Y") . "/ge"
exe "%s/specRPM_CREATION_AUTHOR_MAIL/" . login . "@" . hostname . "/ge"
exe "%s/specRPM_CREATION_NAME/" . expand("%:t:r") . "/ge"
setf spec
endfunction
autocmd BufNewFile	*.spec	call SKEL_spec()
" filetypes
filetype plugin on
filetype indent on
" ~/.vimrc ends here
set nu

No comments have been made. Use this form to start the conversation :)

Leave a Reply