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...

Wednesday, August 24, 2011

Blacklisting a driver

For new computers, there can be a lot of tinkering involved. Ever since I bought a new Asus desktop computer, I've been doing a lot of that - and it's been great! If only the building process took a little bit longer than 25mins :(...

Generally, I've found Ubuntu Linux great for computers. Both of my laptops have worked well - after a clean installation of Ubuntu, all my hardware is usually detected correctly. It's quite pleasant. When clean installing Windoze on the other hand - I have to hunt around the web and download the exact driver for the exact model hardware. But I won't go there.

This will be a quick blog about the Realtek LAN card on my new computer (see specs below). The problem: the driver loaded by Ubuntu, r8169, appears to be faulty once the clean installation is complete and I upgrade all necessary packages. Solution: install the driver from the Realtek website, r8168, restart /etc/init.d/networking and you should be fine.

Desktop specs:
Motherboard: ASUS M5A88-M
Realtek Card (on-board): 8111E/8168B

But, Ubuntu tries to be clever (and I enjoy it when it does :D) and resets the driver to r8169 when you restart the computer. So one solution put to me was to blacklist the r8169 and set the r8168 as the default (NB: my terminology is incorrect, r8168 may not be the correct name for the 'driver'). praseodym from UbuntuForums gave me this suggestion, and the method for implementation is at this UF thread.

Alternatively, I came across another thread which appears to be a duplicate of my problem - although worded differently. The suggestion here is to upgrade the kernel to 2.6.39 and the problem should go away.

Seeing as my system is running and has a continuous connection...I might try that another time.

Why fix it if it ain't broke?

Ciao!

Update - 28 Nov 2011:
There was an update just the other day of a few hundred meg, after which I found that I was having trouble with my connection. What I found was that the 'new' driver had been reinstalled and thus started giving me the up/down problem again. Had to back track a bit because I had forgotten just how I installed it last time.

The Realtek driver download was fine, but because I'm running kernel version 3.0, I suspect that the autorun.sh file was unable to execute properly. Did a quick search and found this website with a run down for those not on 2.4x or 2.6x linux systems.

Connection is working now. :D!

Sunday, August 14, 2011

Windows USB Bootable

Much of the last weekend was spent trying to figure out how to make a USB Flash drive bootable for a Windows installation. This is no simple task, especially if you don't have a spare Windows computer up and running. But if you do, then you are in luck.

Before I attempted to use the Windows app, I did try several Linux options. UnetBootin, the CLI dd command were both promising options (see links below). However, the system I was trying to clean install did not have the appropriate boot options and so the drive was not detected on startup. This may have been a problem that was unique to me, so I would advise giving these options a go...then as a last resort, use the Windows app (Note: You won't turn into a blood-sucking parasite for using this method, but you will feel strange afterwards).

So, yes, if you want to make a Windows 7 bootable USB Flash, then I went to the Microsoft website and downloaded it an ran it on a Windows machine. Link here. Until I can find another way to do it, this will have to do.

Ciao!

Links:
http://www.webupd8.org/2010/10/create-bootable-windows-7-usb-drive.html
Good, but didn't work for me - http://serverfault.com/questions/6714/how-to-make-windows-7-usb-flash-install-media-from-linux

Update: 20 Dec 2011

Good news everyone! lol...link to the Professor Farnsworth, because it's worth it.

But on a serious note, I have just found a a simpler way to make a Windows USB boot drive. And by simpler, I mean on the command line :P.

The video here tells it all, but I'll summarize here, for the sake of documentation. Big thanks to uniquefree, as I for one would never have figured this out.

Briefly, the method:
  1. wipes and formats the usb drive using FAT32 or NTFS file system
  2. copies the files from the Windows CD/DVD straight over to the drive
I'll have to give this a go in Linux. However, at present, I'm not having much luck reading/writing to NTFS or FAT32 usb file systems :(.

Format the USB

For this example, we want to copy files from a CD/DVD drive or even a mounted .iso image at the location D:\, to our USB which will be F:\. This will obviously be different for you.

Start by partitioning the USB, using DISKPART and the following commands:
C:\>DISKPART
DISKPART> list disk
DISKPART> select disk 3
DISKPART> clean
DISKPART> create partition primary
DISKPART> select partition 1
DISKPART> active
DISKPART> format fs=fat32
DISKPART> assign
DISKPART> exit
You still need a windows computer for this one. Open the command prompt, cmd.exe, and type in DISKPART. This program should come preinstalled. The first few commands are important. Use 'list dist' to print out all the drives that have been detected by Windows. Like uniqueparts' video, there will be corresponding number down the left hand side of the output. Find the number that corresponds to the USB drive that you want to move the files to, and use it with the next command. This is important because if you choose the wrong number, the usb drive may not work (because the files were never copied there).

Uniquepart makes this quite clear, so I thought I'd do the same. I'm wondering if the 'Quick format' option that some people are familiar with would still make a bootable usb, but as yet, the longer format option given here is the way that works.


Now, the USB is ready, copy the files over using xcopy:
C:\>xcopy D:\*.* /s/e/f F:\
And you should have it!

This method is much more appealing to me and I hope it makes installs much more pleasant for those who use Windows...hehehe.

Ciao!

Friday, July 1, 2011

Server Fstab

Just making a quick post to get this month started.

My server box has been running really well. The simplicity of the components appears to be holding up - I still haven't found a proper benchmarking tool to test it out but oh well, another day. For now, I've attached several external hard drives so that I can play them on either of my laptops. Using the smb client has proven to be very successful, even over wireless the network. My housemate states that often videos will skip when she plays them on her computer, however this is not the case on my computers so we are both assuming that her computer does not have enough processing power to play the videos. An easy solution would be to use a wired connection - and we might just do that in due time.

What I would like to post today is my current /etc/fstab file. I've finally decided to read a bit about fstab configuration and now I'm wondering why I didn't do it earlier - it's really simple! As always, there is good documentation from the Ubuntu website. There is an example of an fstab entry and as you will see, they are not much different from a mount command.

To find out information about the devices that are connected, use blkid - the output will look like the following:

sudo blkid

/dev/sdc1: LABEL="A-hard-drive" UUID="12B0WF25B0DF0KDB" TYPE="ntfs"
/dev/sdd1: LABEL="Another-hard-drive" UUID="554123D9E73ABF54" TYPE="ntfs"

Take note of the UUID and the TYPE. These will be used in your new fstab file.

Go to /etc/fstab and make a copy of the original file, just incase something goes horribly wrong. I usually just append .orig to the end of the file (fstab.orig), that way it can be found easily again later. If you append orig. to the start (orig.fstab), then you might have trouble finding it later.
sudo cp /etc/fstab /etc/fstab.orig

Open up /etc/fstab with your favourite editor, I use nano since I don't know emacs...yet :). Your original file will look a bit like this, thought it may have more entries depending on how you setup your distro.
sudo nano /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
#                
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/sda1       /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda5 during installation
UUID=5efe42d5-1b11-4287-a604-diid345b63d6 /home           ext4    defaults        0       2
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

So alls you gots to do, is add your entries to the end of this file. Easy huh? From blkid before, you'll need to take the UUID and use that so the computer can identify the external HDD if it happens to be plugged in. I'm hoping that you have read the Ubuntu Docs I linked to before, and you will know that the syntax is something along the lines of:

[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]

That said, for me, I just add these two lines to the end of fstab and my configuration is complete:

UUID=12B0WF25B0DF0KDB /media/OneTouch ntfs-3g uid=user,gid=group-name,umask=0000
UUID=554123D9E73ABF54 /media/Elements ntfs-3g uid=user,gid=group-name,umask=0000

Final file:

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
#                
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/sda1       /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda5 during installation
UUID=5efe42d5-1b11-4287-a604-diid345b63d6 /home           ext4    defaults        0       2
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
UUID=12B0WF25B0DF0KDB /media/OneTouch ntfs-3g uid=user,gid=group-name,umask=0000
UUID=554123D9E73ABF54 /media/Elements ntfs-3g uid=user,gid=group-name,umask=0000

Important! The security of your filesystems is solely up to you. I have used ntfs-3g because this allows users to write to the filesystem. More info about which is the correct filesystem to mount an external as can be read here. Also, by setting uid and gid, you can permit only certain persons to access the filesystems. I believe I have mentioned this before, but no harm in mentioning it again right? Call me paranoid, call me what you will...

Hope this guide is useful, I'm sure I'll be reading it again in the future, when my server dies or I forget what an fstab is.

Adios, till next time!

Thursday, June 23, 2011

Dialog from Kristinn Hrafnsson

Making my way towards the Griffith University, Queensland Conservation of Art on a very fine winter day has given me to opportunity, and many others, to partake in a public forum addressed by spokesman Kristinn Hrafnsson.

Dialog from the address, quoted and revised:

Snippet from leaked US-Army video -> Collateral Damage

Media partners: NY Times, Le Monde, El Pais, Aljazeera, Der Spiegel, SVT, 4, The Guardian

"...only about 50,000 cables are online."

"Often media companies are untrustworthy and individual journalists are consulted."

"Care is made not to make unnecessary harm to people."

"The cables have demystified other information."

"...that the cables will have a devastating effect on information connections between countries."

Zine El Abidine Ben Ali is the president of Tunisia whom is regarded as a valuable alli to certain parties in USA.

GITMO FILES (Guantanimo Bay Files) - an example of bad information being used to detain a number of people in conditions that do not fall under the Universal Declaration of Human Rights.

WikiLeaks has revolutionized journalism by partnering with media corps to better understand the importance of freedom of information.

"In a race between truth and secrecy, truth will always win." Kristinn says that he was impressed by these words, up until he discovered the creator of the saying, Rupert Murdoch.

WikiLeaks exists only due to the need for its' service - once Governments can become transient in relaying information to the public, WikiLeaks may not need to exist.

Saturday, June 11, 2011

Permissions for mounting Externals


When mounting Externals, often the default permission will be that of the user mounting the device. This can create a barrier when wanting to access the External over a network. So when mounting, it is good practice to give suitable permissions that meet your specific needs. Ubuntu Docs has a good page on permissions however, you probably just want a working example. So here you go.

For mount, the umask detemines the permissions and if you read the Ubuntu Docs page briefly, read, write and execute permissions are given by 4, 2 and 1 respectively. As you will see, 0000 will result in permissions = drwxrwxrwx. If you give umask = 0001, then the permissions = drwxrwxrw-. A simple concept, however, at first I thought that it was the other way around.

So here's how I would mount an External on my server for read/write access by guests/users in the specified group:
mount -t ntfs-3g -o uid=admin-user,gid=guest-user-group,umask=0000 /dev/sdc1 /media/OneTouch

And if I wanted to mount with permission for just the user who mounted it:
mount -t ntfs-3g -o uid=admin-user,gid=guest-user-group,umask=0027 /dev/sdc1 /media/OneTouch

Extra control can be given using uid and gid to determine who is the owner and which users of the group can access the External. This may take a little bit extra to tweak but can be a good security measure. To get started, use the following command to determine which group a users belongs to:
id username

For more information about mounting, there's a resource here.

Adios, till next time!