Computers

Care and feeding of computers

Cron jobs in Linux

Ok, so you want Linux to run a job at a set time each day. No problem, Google "cron job" and there is a world of info for you. BUT what if you are a noobe and what if your cron job doesn't work, then what? Well, Bens not guaranteeing that his problem will be the same as yours, but he couldn't find any info on how to trouble shoot them, so here it is......

First up you can not edit the crontab job with VI, you have to use crontab -e. This will edit the job that is called the user you are logged in as and it will be located in /var/spool/cron/crontab.

Look on the web for what all the time and stuff means, its pretty straight forward.

Bens problem was that the job worked if you ran it manually, but it would not run at its scheduled time. He tried copying it to /cron.daily, but again, it did not run, he renamed it from the user name to something else (Important, in Linux, don't ever call a file a user name or test (there is a command called test), but still it would not run at its appointed time.

So, back to crontab, he then added a line that would point to a nonexistent file, this made it easer to grep the log..... previous to all this it was hard to find any errors in the log because the crontab job is called the same a the user. So, when run, the file gave an error, this was something, as up till now Ben didn't even know if the job was running. So, if it was running, why was it not doing what it should? Remember, the job worked fine when run from the shell.

Turns out it is because there is no path set for cron(tab) jobs. So, you must have the explicit path to the command. Ben didn't, he just had logresolve2, not /etc/sbin/logresolve2. Hence the job not running. Why no error? Don't know, njh says Ben should put in a bug report. He didn't. The way to report bugs is not noobe friendly.

crontab -e Edit your crontab file, or create one if it doesn't already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)

*     *   *   *    *  command to be executed
-     -    -    -    -
|     |     |     |     |
|     |     |     |     +----- day of week (0 - 6) (Sunday=0)
|     |     |     +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)
 

DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.iGAp3u/crontab installed on Tue Jan 4 20:34:41 2005)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
13 00 * * * /usr/sbin/logresolve2 < /var/log/apache2/access.log > /var/log/apache2/resolved.log
16 00 * * * /etc/webmin/webalizer/webalizer.pl /var/log/apache2/resolved.log
2,22,32,42,52 * * * * /home/beno/animijobs/vicrain
0 */1 * * * /home/beno/animijobs/austcloud
0 4 */1 * * /home/beno/animijobs/austsolar

url 'http://www.abc.net.au/weather/img/web_sat_aus_latest.jpg' -s -o /var/www/webcams/telescope/austcloud00.jpg
old=00
basepath=/var/www/webcams/animations/austcloud/austcloud
for i in {0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
do cp $basepath$i.jpg $basepath$old.jpg
old=$i
done
cp /var/www/webcams/telescope/austcloud00.jpg /var/www/webcams/animations/austcloud/austcloud15.jpg
convert -delay 25 /var/www/webcams/animations/austcloud/aust*.jpg /var/www/webcams/animations/austcloud/austmake.gif
cp /var/www/webcams/animations/austcloud/austmake.gif /var/www/webcams/animations/austcloud/austcloudanimi.gif

mkdir /mnt/oldhdd then, sudo mount /dev/hda1 /mnt/oldhdd

ncable name server 203.208.81.101 and 203.208.64.10 subnet 255.255.255.0 gateway 203.208.66.1

lspci to get bus location. sudo dpkg-reconfigure xserver-xorg. chown beno.beno -R /var/www. kdesu kcontrol or sudo kcontrol.

/etc/X11/xorg.conf. www.redhat.com/archives/rhl-list/2005-July/msg00341.html to get instructions about installing a matrox millenium g450 duel head card under linux

Common chmods, 777, 744, 655(?). This page here has a really cool calculator to work out the chmod numbers.

sudo groupadd ftp-webcams then sudo chown root:ftp-webcams /var/www/webcams then sudo useradd -g ftp-webcams -d /var/www/webcams/workroof workroof then sudo passwd workroof check /etc/vsftpd.conf

CPU fluctuating under WinXP.

There is somthing going on with my computer. The CPU is hoping all over the place and it generaly is making the computer run like a P2 300mHz. It got so bad that I got a new hard drive and reloaded from scratch. It worked a treat for about 3 months then all of a sudden, it was back to its old tricks. (It actuly happen over night, so it was not somthing I installed!)

(Click on it for a bigger clearer version)

Here you can see it running fine, then I trigger it for a while, then turn it off.

So what was it? Well, as it happens there is no one fix for everyone with this problem. What worked for me may not work for you, but the fact remains, this is a common problem. So, here is what some time on the web turned up for me.

1. Disable Netbios on WINS in TCP/IP properties.

2. If you have more than one hdd, check your master slave jumpers on each.

3. Check your HOSTS file. It should only have one reference to 127.0.0.1

4. Try running sfc /scanonce from a DOS prompt.

5. Turn off indexing services.

6. Unplug all USB devices.

7. Uninstall hotfix KB835732

8. Unplug your parallel port scanner.

9. Delete all your temporary Internet files.

In my case, the parallel scanner that I have owned for some 3-4 years was the nasty. Why? I have no idea. It has been working on the first build for some years before XP started to play up. It was plugged in during the 2nd build from the very start. I now just turn it off at the wall untill I need it. Go figure.

How do you know if you have the right kernel installed on your Linux PC?

This was the question I faced after I built the new server. I had read that (K)Ubuntu simply installs a default 386 kernel. This will get you up and running, sure, but if you have a pretty grunty CPU it may not be getting used to its full potential. Also, if you have a new P4 with Hyperthreading, you really should install an SMP (Shared Multi Processor) kernel? So, like I said, how do you find out what processor is installed on your linux PC? You could reboot and poke around in the BIOS, that might show you a little info, but Im not sure if it will give you all the info needed to make an informed decision about what kernel to install.
A little digging on Google turned up this guys web page.
If you do an 'sudo apt-get install x86info' with Ubuntu, it will put it in a different place than his script will want, so go in and edit his script, change line 38 from /usr/sbin/x86info to /usr/bin/x86info. (Or you can download the dapper one here)Then you have to 'sudo chmod 744 CheckProcs.txt' to make it executable, then its a simple matter of 'sudo ./CheckProcs.txt' to see what you have.
Now you are a little more equipped to make an informed decision about what you have hardware wise and thus what you need kernel wise.

This is a real rough guide on how to install xephem in (k)ubuntu dapper (6.06).

Open your package manager and install libmotif3 and libmotif-dev. I then sudo apt-get install libc6-dv gcc-3.4 libxmu-dev
Then go to: http://www.clearskyinstitute.com/xephem/. Download it to a directory, for instance your user directory, and ungzip/untar it. It'll be in a directory named "xephem-3.7.1" Yes, I know, on that web site, there are some pre-compiled binaries for all that other motif stuff that might work, but I did it this way and I know it works, so you can do what you want and let me know either way......
Then, cd into xephem-3.7.1/libz and sudo vi Makefile Make the following changes;
Make sure the file looks like this:

CC = gcc
CLDFLAGS = -g
CFLAGS = $(CLDFLAGS) -Wall -O2
LDFLAGS =
.............<leave the middle stuff>...........
gcc $(LDFLAGS) -o testzlib testzlib.o libz.a
clean:
rm -f *.o *.a testzlib

Once that all looks good, go to the xephem-3.7.1/GUI/xephem directory and issue this command:
make MOTIF=/usr/lib

It will take a while to make, but at the end of it there should be no errors and you can run it by going into the /GUI/xephem directory and typing ./xephem
Enjoy, its a pretty cool program, I have only just started messing with it, but I suspect that in due course I will pay the money and get the full version.