Wednesday, September 21, 2011

Crontab

When editing crontabs, you must edit the root cron. I found that editing the user cron file, will not run the script which you desire. Today I've read that Crontab is a file/process which acts to automate script files insync with time. The best example of what a Cronjob is, are monthly backups that people perform incase data becomes corrupt or they get a virus. Rather than doing it manually, or downloading some process heavy software to do it for you, you edit the Crontab file, and specify script/s that you want to run.

Below will be the list of code you will use + an example in which you can see if you have set up a Cronjob correctly. Yes, I'm one of those people whom enjoy peace of mind - knowing something works is better than thinking something works.

Here's what you need - but don't execute them yet, keep reading:
$ sudo crontab -e # To access the root cron file
$ sudo touch /etc/cron.d/ # To refresh the cron process with your new settings

The first time you access the crontab file, it will ask you what editor you wish to use - I use nano. I'm puzzled about the location of the crontab file as I originally thought /tmp files were deleted on shutdown. Anywho...the default crontab might look like this:

# 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

The information you need to know about the Cronfile, and editing, it are in the Cronfile itself. But here's a quick run down.

You add a cronjob by using the following syntax:
* * * * * /path/to/crontest.sh

Notice there are 5 positions. From left to right they specify:
  1. Minute, 0 - 59
  2. Hour, 0 - 23
  3. Day of month, 1 - 31
  4. Month, 1 - 12
  5. Day of week, 0 (Sunday) - 6 (Saturday)
So cronjobs are on an annual cycle. The asterisks example is basically telling the computer that the cronjob is to be run every minute.

Testing Crontab/Cronjobs
Here's a quick way to test crontab.

1) Open terminal and move to a directory of your choice.

2) Make a new file and call it "crontest.sh".

3) Give crontest.sh user executable permissions. Or 755, which also enables write-perms:
$ sudo chmod u+x crontest.sh

4) In crontest.sh, add this script. This is just a script that echos the date, given the format you desire.
#!/bin/bash

date +"%d-%m-%Y" >> /path/to/the/storage/file.txt # Date ID, >> tells terminal to append to end of file

Save and exit.

5) Open up the crontab file:
$ sudo crontab -e

6) Look at the current time and edit the crontab file with a few minutes added to the current time. So, if the time is 17:40, make the crontab entry look like this:
...
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
45 17 * * 1-5 /path/to/crontest.sh

Close nano and save the changes.

7) Now refresh crontab:
sudo touch /etc/cron.d/

Giving your password where required.

8) Sit and wait. When 17:45 comes around, the script will be run. Check the /path/to/the/storage/file.txt file and see if the date is there. If yes, then your method is good. If no, then check that permissions are correct; check that the code and all pathways are right.

Hope you enjoy this HowTo. I'm probably going to make a cronjob to append CPU temps to a file such that I can graph them and see if certain parameters are better/worse for my CPU performance.

Here are two sites which I found helpful:
http://klenwell.com/press/2010/11/cron-d/
http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/

Enjoy, Ciao!

Tuesday, September 20, 2011

The journey of overclocking begins!

Overclocking is something that I've always wanted to do. And today, when I should have been finishing an assignment about National Park Management, I decided to read up and perform some overclocking, hehehe.

So far I've:
  • Joined overclockers.com 
  • Overclocked my desktop PC using the preloaded OC profiles on my ASUS motherboard, and
  • Crashed my desktop once -> a BSOD!!

Here's a neat little YouTube vid that I found interesting. The dude states, and it sounds as though this could be the first tenet of overclocking, and that is that the NB Frequency must be equal to or greater than the HT Frequency in order to have a stable system.

NB Frequency >= HT Frequency (But is this true? I'm wondering now.)

I'll be testing this in the next few days to see if that is the case. Also, he suggests that CPU temps that exceed 65 oC may not be very good, so keep that in mind also.

Vid1
Vid2

While it was slightly disheartening when the BSOD came up, I was able to go back to default settings. What troubled me was that when I rebooted, I had somehow lost 1 core - only 5 cores were being detected/used. So even though the settings were on default, I had lost a core. But I soon discovered that the BIOS appears to have individual core on/off settings and 1 of the cores was switched off when the problem was detected. So I turned it on and everything is fine.

But I guess I learned something, don't be in a hurry.

Computer specs:
ASUS M5A88-M Motherboard
AMD Phenom II X6 1075T
2 x 4GB Kingston RAM @ 1333MHz (need to upgrade this next)
And I suppose I should mention that I'm running most of the tests on Windoze 7....


There is a really good AMD Phenom overclocking guide here. But there are no specific posts where people show successful/stable settings. Maybe I can be the first to post one...



According to the AMD Datasheet, there are some max settings which I probably should not exeed. MT/s stands for 1 million transfers per second.

Max DDR speed: 1333 MT/s
Max HT Link speed: 4000 MT/s

Update 9/10/2011:
In regard to doing the system stability tests on Windoze, I am still as yet able to find a Linux CPU stress tester. CPU and MB temps are now docked on the top panel and this is useful. However, I'm skeptical on the accuracy as I'm almost certain that the temp is just a function of the voltage being run through particular components at any one time. As a result, the temperature factor used by Linux may be different to the temperature factor used by Windoze...