Fedora Cron and Anacron Schedule Setup

January 24, 2010

This article assumes that you have the basic knowledge of cron and anacron. With the availability of both cron and anacron tools, different Linux distribution configures their schedule task differently.

For Red Hat Linux and Fedora system, there are also significant changes compared to the previous setup.

Before Fedora 10, the default crontab file is setup as follows:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

In the older version of Red Hat Linux and Fedora, anacron was setup to run during the system boot up and initialization process. A script file named as anacron can be found in /etc/rc.d/init.d, the directory that stores the system boot up script.

However, from Fedora 11 onwards, the cron jobs mentioned above are split between cron and anacron.

The default crontab file has no entries as shown below:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# .—————- minute (0 – 59)
# |  .————- hour (0 – 23)
# |  |  .———- day of month (1 – 31)
# |  |  |  .——- month (1 – 12) OR jan,feb,mar,apr …
# |  |  |  |  .—- day of week (0 – 6) (Sunday=0 or 7)  OR
#sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  command to be executed

So, where are the cron jobs’ configurations? First, all the daily, weekly and monthly scripts are configured under anacrontab and it is set to be run by anacron. The default anacrontab file is as follows:

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
1   65     cron.daily          nice run-parts /etc/cron.daily
7   70     cron.weekly         nice run-parts /etc/cron.weekly
@monthly 75 cron.monthly       nice run-parts /etc/cron.monthly

With anacron running all the scripts located in /etc/cron.daily, cron.weekly and cron.monthly. Cron is left with running the scripts in /etc/cron.hourly. The configuration of the hourly cron job is located at /etc/cron.d/0hourly. The default is as follows:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
01 * * * * root run-parts /etc/cron.hourly

Since anacron is not a daemon, this means that anacron need to be activate by scheduled scripts or command. In Fedora, a script file named “0anacron” is located at /etc/cron.hourly. This indicates that anacron is schedule to run on an hourly basis.

In conclusion, the cron daemon in Fedora now only run the script stored in /etc/cron.hourly which configuration is based on /etc/cron.d/0hourly. In the folder /etc/cron.hourly there is a script that runs anacron on an hourly basis. This anacron script then runs all other scripts in the daily, weekly and monthly folders.

Therefore, from Fedora 11 onwards you need to installed cron and anacron in order to have your system task scheduler running properly.

While this is a good arrangement, since most users do not turn on their PC 24×7, I agreed with some users’ suggestion that Fedora should include additional explanatory notes to explain the new configuration in the file crontab.

If you want to remove anacron and use cron exclusively, you need to use the old configuration of crontab and append to the crontab as shown below:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# .—————- minute (0 – 59)
# |  .————- hour (0 – 23)
# |  |  .———- day of month (1 – 31)
# |  |  |  .——- month (1 – 12) OR jan,feb,mar,apr …
# |  |  |  |  .—- day of week (0 – 6) (Sunday=0 or 7)  OR
#sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  command to be executed
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

It is not advisable to remove cron because anacron cannot run a task at a specific time.

End

Advertisements

Video Problem with GNOME and X Windows in Fedora installed in VirtualBox

January 16, 2010

This article basically address the problem when X Window won’t start after you have installed VirtualBox Guest Addition in Fedora as Guest OS.

If you are using the latest version of VirtualBox and Fedora 12, you should not have any problem with the drivers. The VBox video drivers works well with HAL in Fedora.

However, there is one exception. After installing VirtualBox Guest Addition on Fedora, you can freely adjust the size of the windows in the VirtualBox. If you happen to adjust VirtualBox windows to maximize the full screen on a 22″ or greater LCD, you will have problem starting X Windows on the next reboot. After maximizing the VirtualBox to the maximum, you would not be able to start X Window (specifically gdm) on the next reboot.

Problem

I have a 22″ LCD monitor with default resolution of 1680×1050 in Windows Vista. I have manage to adjust the VirtualBox Window (Fedora 12 as Guest) to 1504×932 without problem restarting Fedora. However, if I maximize the VirtualBox Window to occupy the full screen except Vista status bar (resolution of 1680×957), I would have problem starting X Window on the next reboot.

Solution

There are 2 ways to resolve this issue.

The first solution is NOT to maximize the VirtualBox window before restarting Fedora. If you need to maximize the VirtualBox window to work on Fedora, you must remember to reduce the window back to its original size. This is the easiest solution except that you have to remember to reduce the window before restarting Fedora or shutting down Fedora.

If  you prefer to work on the maximize  VirtualBox window size all the time, you can do so that by reverting to the old method of configuring the screen resolution using configuration file. The second solution is to manually configure screen resolution. Please be aware that after configuring the screen resolution, you cannot adjust VirtualBox window freely anymore.

We use xorg.conf configuration file to configure screen resolution. This file is no longer located at /etc/X11 because Fedora is using HAL to manage video and screen resolution. In the older Fedora system, xorg.conf is the main configuration file for video size, dept and resolution.

How to Login when X Windows Fails to Start

When X Windows fails to start, use the key Ctrl+Fn+F2 or Ctrl+Fn+F3 to switch to another virtual windows using console login.

Creating X11 Video Configuration File (xorg.conf)

Since the new Fedora system don’t use xorg.conf anymore. You couldn’t find it in /etc/X11 folder. To generate this file automatically use the command #Xorg -configure. This command creates a file “xorg.conf.new” after probing the video system. You need to read the output as it indicates where this new file is created.

Then you need to rename the file to xorg.conf and move this configuration file to /etc/X11 folder.

Finally, you need to define the screen resolution in the configuration file.

Amending the Configuration File

Open the file xorg.conf with your favorite editor.

On the section “Screen”, look for subsection “Display” with depth of 24.

Insert a new line indicating the Modes “1680×957”, as follows:

Section “Screen”
Identifier   “Default Screen”
Monitor      “Configured Monitor”
Device      “Configured Video Device”
DefaultDepth    24
SubSection      “Display”
Depth           24
Modes           “1680×957”
EndSubSection
EndSection

The resolution of 1680×957 is the maximize window size excluding the Windows task bar. If you have different screen resolution, please check the most appropriate resolution for your  screen.

Please note that using the xorg.conf will prevents you from adjusting the VirtualBox window dynamically.

If you want to revert to dynamic window adjustment, make sure Fedora is shut down with smaller screen resolution. You can remove the file xorg.conf.

End


No GNOME Desktop Login Sound after Login to Fedora 12

January 15, 2010

This is a minor problem, but some users might want to listen to a welcome tune after login to Fedora 12.

First, get a copy of desktop login tune (desktop-login.ogg) from Fedora 11. You can also download from here: desktop-login.ogg

Then copy this file to the folder /usr/share/sounds/freedesktop/stereo

Logout and login again, you should be able to hear the login tune after login.

If there is still no desktop login sound,  select: System >> Preference >>Startup Applications

Ensure that the application “GNOME login sound” is check. Click edit and make sure that the command /usr/bin/canberra-gtk-play –id=”desktop-login” –description=”GNOME Login” is available.

Depends on the sound drivers and the sound system initiation procedure, some system may not be able to play the sound.

End