1 Programming

Menu path:
Tasks / Cron tasks

Axional Studio provides a tool to be able to parameterize program executions in a certain time.

  • Program execution could be defined for an specific database, if empty will be executed at database 'wic_conf'.
  • The default execution user is 'manager' but it's possible to determine a specific user.
  • Flag control to disable or enable the cron task.
  • Complete parameterization for complex execution times.

Cron expressions are comprised of 6 required fields and one optional field separated by white space.

The fields respectively are described as follows:

Field Name	 	Allowed Values	 	Allowed Special Characters
Seconds	 	        0-59	 	        , - * /
Minutes	 	        0-59	 	        , - * /
Hours	 	        0-23	 	        , - * /
Day-of-month	        1-31	 	        , - * ? / L W
Month	 	        1-12 or JAN-DEC	 	, - * /
Day-of-Week             1-7 or SUN-SAT	 	, - * ? / L #
Year (Optional)	        empty,1970-2199	 	, - * /

The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".

The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fields, but not the other.

The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".

The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".

The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 0 to 11 (JAN to DEC). The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.

The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". You can also specify an offset from the last day of the month, such as "L-3" which would mean the third-to-last day of the calendar month. When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing/unexpected results.

The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.

The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".

The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month. If the '#' character is used, there can only be one expression in the day-of-week field ("3#1,6#3" is not valid, since there are two expressions).

The legal characters and the names of months and days of the week are not case sensitive.

NOTES:

Support for specifying both a day-of-week and a day-of-month value is not complete (you'll need to use the '?' character in one of these fields). Overflowing ranges is supported - that is, having a larger number on the left hand side than the right. You might do 22-2 to catch 10 o'clock at night until 2 o'clock in the morning, or you might have NOV-FEB. It is very important to note that overuse of overflowing ranges creates ranges that don't make sense and no effort has been made to determine which interpretation CronExpression chooses. An example would be "0 0 14-6 ? * FRI-MON".

wic_crontab_tasks
Label Description
Task name Name of the task
Description Description of the cron task
Host Server code where the task is executed
Disable Flag to disable a cron task

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Task state State of the task

  • Default: 0
  • Values:
    • 0: Valid.
    • 1: Invalid.
Execution user If the execution user is not specified, it is the 'manager'. If it is defined, as well as being the execution user, he can see the status and result from the OS application, while all other users in your group will not have access.
Users group Group of users who are allowed to see the status and executions from the OS tool
Database Database where statement cron task will be executed

  • Values:
    • SELECT: .
Seconds Seconds
Minutes Minutes
Hour Hour
Day of the month Day of the month
Month Month
Day of the week Day of the week
Year Year
Cron time error A message will be displayed if exist an error with the cron parametrization
SQL Statement Statement of the cron task that will be executed.
Last execution Last execution of the cron task
Milliseconds Milliseconds used by the program in the execution

  • Default: 0
State State of the last execution

  • Default: 0
  • Values:
    • 0: Finished.
    • 1: In queue.
    • 2: Running.
    • 3: Error.
    • 4: Dead.
Last message Last message of the execution response.
User created User created

  • Default: USER
Date created Date created

  • Default: CURRENT
User update User update

  • Default: USER
Date updated Date updated

  • Default: CURRENT
Actions
Button Title Notes
BUTT_DELETE_EXECUTIONS Remove executions null
 

2 Standard tasks

There are some standard tasks that must be added to the cron.

 

2.1 Remove logs

This task remove old logs in order to prevent store a big history log data that will not be used.

Field Value Field Value
Task name user_remove_logs Seconds 5
Database - Any - Minutes 5
Host [The HOST] Hour 4
Task group Day of the month *
Task user Month *
Disable

Day of the week 1
SQL statement
Copy
begin work;
DELETE FROM wic_user_errlogs    WHERE DATE(log_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_trxlogs    WHERE DATE(log_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_xsllogs    WHERE DATE(log_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_xsqllogs   WHERE DATE(xsql_date)  < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_qrylogs    WHERE DATE(query_date) < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_sqllogs    WHERE DATE(log_date)   < TODAY-60 UNITS DAY AND sql_favorite = 0;
commit;
begin work;
DELETE FROM wic_user_xsltjobs   WHERE DATE(job_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_jrepjobs   WHERE DATE(job_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_cron_sched WHERE DATE(task_date)  < TODAY-30 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_olaplogs   WHERE DATE(log_date)   < TODAY-120 UNITS DAY AND olap_favorite = 0;
commit;
begin work;
DELETE FROM wic_olap_statistics WHERE DATE(log_date)   < TODAY-120 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_olap_errors WHERE DATE(log_date)   < TODAY-120 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_httplogs_hist WHERE DATE(http_access_ini)    < TODAY-90 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_sync_client_iologs WHERE DATE(sync_date)    < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_soaplogs_hist WHERE DATE(soap_access)       < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_soaplogs_ext WHERE DATE(soap_access_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_mobile_devices_data_hist WHERE DATE(device_last_date)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_mobile_devices_geop WHERE DATE(gps_time)   < TODAY-60 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_sync_client_status WHERE DATE(table_date)   < TODAY-30 UNITS DAY;
commit;
begin work;
DELETE FROM wic_user_sync_client_ack_stmt WHERE DATE(stmt_date_created)   < TODAY-60 UNITS DAY;
commit;
 

2.2 Disk quote exceded

This task sends an e-mail to user that has a high ocupation on desktop tools.

Field Value Field Value
Task name user_disk_quote_exceded Seconds 5
Database - Any - Minutes 5
Host [The HOST] Hour 4
Task group Day of the month *
Task user Month *
Disable

Day of the week 1
SQL statement
SQL statement
Copy
<!-- ================================================================================ -->
<!--                                                                                  -->
<!--  XSQL: user_disk_quote_exceded                                                   -->
<!--                                                                                  -->
<!--  Enviar un mail quan estigui prop del límit d'espai.                             -->
<!--                                                                                  -->
<!-- ================================================================================ -->
<call>
<![CDATA[
<xsql-script>
    <body>

        <set name='m_max_pct'>80</set>

        <map name='m_title'>
            <item>ca<string>Axional: Espai utilitzat &gt; <m_max_pct/>%</string></item>
            <item>es<string>Axional: Espacio utilizado &gt; <m_max_pct/>%</string></item>
            <item>en<string>Axional: Used space &gt; <m_max_pct/>%</string></item>
            <item>de<string>Axional: Benutzter Raum &gt; <m_max_pct/>%</string></item>
            <item>pt<string>Axional: Espao usado  &gt; <m_max_pct/>%</string></item>
            <item>fr<string>Axional: L'espace utilis &gt; <m_max_pct/>%</string></item>
            <item>it<string>Axional: Spazio usato &gt; <m_max_pct/>%</string></item>
        </map>

        <function name='mail_content'>
            <args>
                <arg name='l_lang' />
                <arg name='l_pct' />
                <arg name='l_quote' />
            </args>
            <body>
                <switch name='l_lang'>
                    <case value='ca'>
                        <return><string>ATENCIÒ:
Actualment està fent servir un <number type='decimal' scale='2'><l_pct /></number>% de la seva quota total <l_quote />MB per eines d'escriptori a Axional.
Si es queda sense espai lliure i utilitza l'eina de correu d'Axional no podrà rebre correus nous. Aconsellem que disminueixi l'espai utilitzat a fi d'evitar futurs problemes o contacti amb el seu administrador per tal que li assigni més espai.

Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </case>
                    <case value='es'>
                        <return><string>ATENCIÓN:
Actualmente està utilizando un <number type='decimal' scale='2'><l_pct /></number>% de su cuota total de <l_quote />MB para herramientas de escriptorio en Axional.
Si se queda sin espacio libre y utiliza la herramienta de correo de Axional no podrà recibir nuevos correos. Aconsejamos que reduzca el espacio utilizado para evitar futuros problemas o contacte con su administrador para que le asigne más espacio.

Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </case>
                    <case value='de'>
                        <return><string>AUFMERKSAMKEIT:
In dem Augenblick als du ein <number type='decimal' scale='2'><l_pct /></number>% deiner Gesamtquote <l_quote/>MB fer desktop Werkzeuge in Axional benutzt.
Wenn du ohne freien Raum bleibst und du verwendest das mailtool des Axional, das du nicht empfdngst neue E-mails wirst. Wir raten, um den benutzten Raum zu verringern, um Zukunftprobleme zu vermeiden oder Kontakt mit deinem Verwalter, damit er mehr Raum dir zuweist.

Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </case>
                    <case value='fr'>
                        <return><string>ATTENTION :
Au moment od vous employez un <number type='decimal' scale='2'><l_pct /></number>% de votre quote-part totale de <l_quote/>MB pour des outils d'ordinateur de bureau dans Axional.
Si vous restez sans espace libre et vous employez le mailtool de l'Axional que vous ne pourrez pas recevoir de nouveaux E-mails. Nous conseillons de raduire l'espace utilisa pour aviter des problames a terme ou contact avec votre administrateur de sorte qu'il t'assigne plus d'espace.


Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </case>
                    <case value='it'>
                        <return><string>ATTENZIONE:
Dal momento che state usando un <number type='decimal' scale='2'><l_pct /></number>% della vostra quota totale di <l_quote/>MB per gli attrezzi desktop in Axional.
Se rimanete senza spazio libero ed usate il mailtool che del Axional non potrete ricevere i nuovi E-maili. Raccomandiamo per ridurre lo spazio usato per evitare i problemi a termine o contatto con il vostro coordinatore in modo che assegni pia spazio voi.


Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </case>
                    <case value='pt'>
                        <return><string>ATENÇAO:
No momento em que voca esta usando um <number type='decimal' scale='2'><l_pct /></number>% de seu quota total do <l_quote/>MB para ferramentas desktop em Axional.
Se voca remanescer sem espaao livre e voca usa o mailtool que do Axional voca nao recebe E-mais novos . Nas recomendamos para reduzir o espaao usado para evitar problemas dos futuros ou contato com seu administrador de modo que lhe atribua mais espaao.


Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </case>
                    <default>
                        <return><string>ATTENTION:
At the moment you are using a <number type='decimal' scale='2'><l_pct /></number>% of your total quota of <l_quote />MB for desktop tools in Axional.
If you remain without free space and you use the Axional's mailtool you will not be able to receive new e-mails. We advised to reduce the used space to avoid future problems or contact with your administrator so that it assigns more space to you.

Axional, <system.getHost/> (<system.getAddr/>)
                        </string></return>
                    </default>
                </switch>

            </body>
        </function>

        <connection name='wic_conf'>

            <foreach>
                <select prefix='m_'>
                    <columns>
                        user_mail, user_name, user_code, user_lang, user_disksize,
                        (
                        (<select>
                            <columns>
                                <nvl>
                                    SUM(tree_size),0
                                </nvl>
                            </columns>
                            <from table='wic_user_disktree' />
                            <where>
                                wic_user_disktree.user_code = wic_user.user_code
                            </where>
                        </select>)
                        +
                        (<select>
                            <columns>
                                <nvl>
                                    SUM(file_size),0
                                </nvl>
                            </columns>
                            <from table='wic_user_diskdata' />
                            <where>
                                wic_user_diskdata.user_code = wic_user.user_code
                                AND wic_user_diskdata.tree_id &lt;= 0
                            </where>
                        </select>)
                        +
                        (<select>
                            <columns>
                                <nvl>
                                    SUM(tree_size),0
                                </nvl>
                            </columns>
                            <from table='wic_user_mailtree' />
                            <where>
                                wic_user_mailtree.user_code = wic_user.user_code
                            </where>
                        </select>)
                        +
                        (<select>
                            <columns>
                                <nvl>
                                    SUM(mail_size),0
                                </nvl>
                            </columns>
                            <from table='wic_user_maildata' />
                            <where>
                                wic_user_maildata.user_code = wic_user.user_code
                                AND wic_user_maildata.tree_id &lt;= 0
                            </where>
                        </select>)
                        )
                        * 100 / (user_disksize * 1024 * 1024) pct
                    </columns>
                    <from table='wic_user' />
                </select>
                <do>
                    <if>
                        <expr>
                            <ge>
                                <m_pct />
                                <m_max_pct />
                            </ge>
                        </expr>
                        <then>

                            <try>
                                <body>
                                    <set name="m_subject"><string><map.get name='m_title'><m_user_lang /></map.get></string></set>
                                    <set name='m_to'><string><m_user_name/>&lt;<m_user_mail />&gt;</string>
                                    </set>

                                    <mail
                                        from='no-reply@deister.es'
                                        to='#m_to'
                                        subject='#m_subject'
                                        type='text/html'>
                                        <content><mail_content><m_user_lang /><m_pct /><m_user_disksize /></mail_content></content>
                                    </mail>
                                </body>
                                <catch>
                                    <return>0</return>
                                </catch>
                            </try>
                        </then>
                    </if>
                </do>
            </foreach>

        </connection>

    </body>

</xsql-script>
]]>
</call>
 

3 Programing time examples

At 5 seconds past the minute, every 5 minutes, starting at minutes past the hour, Monday through Sunday At 04:30 AM
At 09:05 AM and 06:05 PM Every 2 minutes, starting at minutes past the hour, Tuesday through Sunday