Linux Utilities

 

date - Display/Change system date and time

The command date is used to display or change the system time.

Examples:

  • date - Displays current date/time:  Sun Jun 11 12:56:54 CDT 2000
  • date MMDDhhmmCCYY.ss - Sets the system date. (Note: must be logged in as root)
    • MM month
    • DD day within month
    • hh hour
    • mm minute
    • CC first two digits of year (optional)
    • YY last two digits of year (optional)
    • ss second (optional)

top of page


cal - Display a calendar

cal is used to display a calendar.  The command can display a calendar for the current month, any year or any month for a given year.

Options:
<MM> <YYYY>
Displays a calendar for the specified month and year. The year must be a four digit value.

<YYYY>
Displays a calendar for all months for the specified year.

Examples:

  • cal - Displays current month only
  • cal 1998 - Displays all months for 1998
  • cal 3 1999 - Displays a calendar for March of 1999

top of page


Clear the screen

Example: clear - Will clear the screen.

top of page


touch - Change access time for a file

The command touch will set the last access and modified time to the current system time for the specific file. Note: If the specified file does not exist, this command will create the file.

Example: touch /etc/profile - changes the date/time of /etc/profile

top of page


Get help

There are two handy utilities that will display manual pages for Linux commands and utilities: man or info.

man

For the command man

  • the displayed information is 'piped' to the 'less' command
  • Use the space bar for next page
  • q to exit.

Example: man ls - Displays instructions on how to use the 'ls' command

info

The command info is more complex to use and recommend you enter h for help to get instructions. Info has hyperlinks to enable you to jump to different sections of the manual.

Examples:

  • info - Displays instructions on how to use info and a table of contents
  • info ls - Displays help for the command ls

top of page


crontab - Schedule Jobs or Tasks

Crontab is a program that allows users to create jobs that will run at a given time. Each individual user has their own crontab and the entire system has a crontab that can only be modified using root access. If you are adding a crontab for an individual user you must sign on as that user first.

Options:

  • crontab -e - Edits the current crontab or creates a new one.
  • crontab -l - Lists the contents of the crontab file.
  • crontab -r - Removes the crontab file.

Note: Do not enter just the crontab command without a parameter. On some systems it will remove the crontab file.

There are six fields for each entry, each separated by a space or tab.

  • The first five fields specify when the command is to be run
  • Sixth field is the command itself.
  • Minute - 0-59
    Hour
    - 0-23 24-hour format
    Day - 1-31 Day of the month
    Month - 1-12 Month of the year
    Weekday - 0-6 Day of the week. 0 refers to Sunday

    Time formats...

    Every instance - An asterisk (*) is used to indicate that every instance (i.e. every hour, every weekday, etc.) of the particular time period will be used.

    Example: * 23 * * * - Executes at 11PM every day

    List - If you wish to use more than one instance of a particular time periods, then seperate the values by a comma.

    Example: 5,35 * * * 1-5 - Executes at :05 and :35 past the hour, every hour, Monday through Friday

    Range - If you wish for continuous execution, the start and stop items are separated by a dash.

    Example: 8-11 - For an hours entry executes at hours 8, 9, 10 and 11

    Step - Step values can be used in conjunction with ranges. Following a range with /<number> specifies skips of the number's value through the range. Steps are also permitted after an asterisk

    Example: 0-23/2 - In the hours field executes every other hour
    Example: 1-9/2 - Is the same as 1,3,5,7,9
    Example: */2 - Executes every two hours

    Names - Can be used for the month and day of week fields. Use the first three letters of the particular day or month (case doesn't matter). Ranges or lists of names are not allowed.

    When specifying day of week, both day 0 and day 7 will be considered Sunday.

    Command - The last entry specifies the actual script to execute. Make sure you enter the full path name for the command. Also make sure your script has a full path name references to files or other programs or scripts that it may execute.

Email Option

By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command at the end of the cron job line...
>/dev/null 2>&1

Log File

To collect the cron execution execution log in a file...
30 18 * * * rm /home/someuser/tmp/* > /var/logs/cleantmp.log

top of page

 

Services | Products | Support | What's New | Online Shopping | Online Help | Privacy Policy | Legal Stuff

Email us at Info@AHinc.com
© 1993-2005 Advanced Horizons, Inc. - All Rights Reserved