Linux Blog

Crontabs 101

Filed under: Shell Script Sundays — TheLinuxBlog.com at 11:42 pm on Sunday, January 4, 2009

Although not necessarily classified as shell scripting its self cron’s are very useful to any Linux administrators arsenal. The ability to run tasks at a specific interval is a great way to schedule things to run later or when the system load is lower. Many applications use crontab to schedule tasks so its hard to say what yours will look like.

crontab -l

will list all of the cron jobs scheduled for the currently logged in user mine has an entry for kpodder

# (Cron version V5.0 — $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
#KPodder entries
0 0 * * * kpodder.sh -c “/home/owen/.kde/share/apps/kpodder/” -s “global.casts” -o “/home/owen/podcasts” -d 0
#KPodder End

The first five fields are to tell the task when to run. They are in the following order: minute, hour, day, month, day of the week. Asterisks are used to say any valid value and a forward slash can be used to make intervals such as five minutes, hours, days or months (*/5). A comma can be used for or values, so if used as 2,4,6 the cron would run at 2, 4 or 6 o’clock. Dashes are used for time spans, If you have an 8-5 work day you can use 8-17 if in the hours field.

Next, the sixth field is the actual program to run. It will look in the $PATH for the user, but for safety’s sake, I try to use the full path if possible. In my example of the kpodder script there are many arguments. I only really use simple crons and the number of arguments here seems rather excessive.

To edit the crontab do crontab -e. This will edit the current users crontab. If you are root and wish to edit a naughty cron from another user you use -u and specify the user.

Thats pretty much all there is to it. I’d love to here tips and how much people love/hate cron and why.

Happy Shell Scripting New Year,

- Owen.

General Linux Change Password

Filed under: General Linux,Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 4:52 am on Thursday, December 20, 2007

Changing your password under Linux is a pretty simple task providing you know how to do it, and of course since we’re talking about Linux: changing your password is as simple or complicated as you want it to be either way. You either love GUI’s or you hate them, so one method or the other can be confusing. I’m more of a console guy, but I’ll start with the GUI methods because thats probably what I think the masses want to see first. Remember what your doing tho, if you need to change the password on more than one box, I would look into changing your password by command line.

There is more than one reason to change your password, the examples below assume that you are just changing the current users password because it needs to be changed.

kdepasswd

kdepasswd example

passwd

linux change passwd

If you need to change the password for another user, log in as root and execute the following:

passwd (username)

linux change passwd

There are many ways to change your root password if you forgot it.

One way to do it is to boot up with a live CD, mount your hard drive, chroot and then execute the passwd command, once you reboot your password should be reset.