Knowledge Base Glossary       Exit
(how to) Search  

Browse by Category
Knowledge Base > Products > Image for Linux > FAQ > How to run IFL commands from a cron job

How to run IFL commands from a cron job

Because the IFL program (imagel) is normally attached to a terminal, attempting to run an imagel command from a cron job will result in an error message such as "error opening terminal", and the command will fail to execute.

To successfully run an imagel command line from a cron job, it is necessary to add the line 'TERM=dumb' to the cron job file as shown in the following example:

# m  h  dom  mon  dow  command
30  5  *  *  *  /home/user/imagel  -b --uy --d:0@0x1 --f:/home/user/images/debian   > /dev/null

The above would cause cron to run this job at 5:30 AM every day, and it would create an image from partition ID=1 on drive 0 to a file named debian.tbi in the /home/user/images directory.  The --uy option causes IFL to overwrite the previous image file without confirmation. The redirection of the command's output to /dev/null is not required, but will prevent cron from sending an email containing the screen output of imagel each time the job runs. If you do want to receive email notification that the cron job was run, the following is an example of how that could be accomplished:

# m  h  dom  mon  dow  command
30  5  *  *  *  /home/user/imagel  -b --uy --d:0@0x1 --f:/home/user/images/debian >  /dev/null
30  5  *  *  *  /bin/echo "Cron job to create debian.tbi image has been executed"

Note that the cron job above is for a user crontab file (the IFL command will run as a user, not as root), and does not have a user field. The typical procedure to set up a user crontab is to create a text file in the above format with the desired command(s), and then run the command 'crontab <file>'.  Doing this will install the crontab file in the /var/spool/cron/crontabs directory. The file in the crontabs directory will be renamed to the user's user name.

Also be aware that the 'crontab <file>' command will replace any existing crontab for that user.  If you wish to edit an existing crontab to add IFL commands, the 'crontab -e' command can be used for that purpose.  Please see the crontab man page for complete information about the crontab command and the format of the crontab file. Also see the crontab(5) man page (man 5 crontab) for information about the system crontab (as opposed to a user crontab).

If the cron job is calling a script, which in turn runs the imagel command(s), the IFL/terminal issue can be handled in one of two ways:

  1. Include the line "TERM=dumb" in the crontab file that calls the IFL script (as shown above.)

  2. Include the line "export TERM=dumb" in the IFL script. This has the advantage of being able to use the same crontab to schedule other tasks for which the "TERM=dumb" line in the crontab may be a problem. The following is an example script:

    #! /bin/sh
    export TERM=dumb
    /home/user/imagel  -b --uy --d:0@0x1 --f:/home/user/images/debian  >  /dev/null

    The script above could be called from a crontab such as the following:

    # m  h  dom  mon  dow  command
    30  5  *  *  *  /home/user/script


How helpful was this article to you?

powered by Lore