Infrastructure at your Service

Nabil Saoual

Control-M/EM Import/Export Calendar

By February 10, 2020 Control-M 2 Comments

Control-M: Export/Import Calendars


What is a Control M Calendar?

A Control M calendar is used to schedule Control M jobs that are assigned to him:

For example the job named JOB_TEST will be executed depending of the days and rules defined in the calendar named CALENDAR_EXAMPLE_1 :

You can see that the job is scheduled following the calendars rules (by selecting View schedule)

Also you can list the calendars available in the tools tab of the GUI:

You can find your defined calendars following tools and selecting calendars tab,then you can perform some actions like duplicating or update them but sadly there is no way to import or export  them from here:

For that we have to you use another way:

We will have to connect to a shell and use the emdef utility.

Below a quick description of possible actions on Calendar definitions using emdef utility (you can use the help option of Control M Gui to get more infos)

You can also get further by consulting David’s blog explaining some interesting functions of the emdef utility with calendars extractions but also with folders extractions following this other blog .

Here we are:

The purpose is to perform an export of an existing calendar in order to backup it or to use it on another Control M server (it must be imported for that and this will be explained further)

Exporting a calendar :

In the following example we want to export a calendar named CALENDAR_EXAMPLE_1 from my controlm server named ctmservercentos in a file named /tmp/CALENDAR_EXAMPLE_1_exported.xml.By the way the datacenter name is also named ctmservercentos

You have to open a command prompt and proceed like below :

Tip on Unix : You can have the datacenter name by typing this command:

[[email protected] tmp]$ ps -eaf | grep gtw
emuser 21889 1 0 févr.09 ? 00:00:00 /bin/sh /home/emuser/ctm_em/bin/em gtw -dc CTMSRVCENTOS
emuser 21944 21889 0 févr.09 ? 00:00:27 emgtw -dc CTMSRVCENTOS
emuser 28556 26207 0 13:51 pts/4 00:00:00 grep --color=auto gtw
[[email protected] tmp]$

First step : Create a .xml file containing the informations below :

cat /tmp/caltmp.xml

Second step :Use the « emdef » utility to get the file exported:

emdef exportdefcal -u controlm_username -p " controlm_username_passwd" -s ctmserver_name -arg "/tmp/caltmp.xml" -out "/tmp/CALENDAR_NAME_exported.xml"


[[email protected] tmp]$ emdef exportdefcal -u emuser -p "N********DBI" -s CTMSRVCENTOS  -arg "/tmp/caltmp.xml" -out "/tmp/CALENDAR_EXAMPLE_1_exported.xml"
1 calendars were exported.
Writing calendars to file /tmp/CALENDAR_EXAMPLE_1_exported.xml

As result you have a new file generated named CALENDAR_EXAMPLE_1_exported.xml you can verify if it is corresponding to the file calendar we wanted to export:

[[email protected] tmp]$ cat /tmp/CALENDAR_EXAMPLE_1_exported.xml
<?xml version='1.0' encoding='ISO-8859-1' ?>
[[email protected] tmp]$

Importing calendar to another control M server

Now we have exported calendar we can use it on another Control M server to schedule jobs.

Below we will describe the task to do and the prerequisites to check:

  • Delete or rename the calendar if it already exists
  • Copy in the /tmp file the calendar exported in the previous part explianing the calendar export (CALENDAR_EXAMPLE_1_exported.xml)
  • Check  if  DATACENTER is correct in the xml

After these checks we can connect to the other Control M Server we want to import this calendar threw a linux shell and use again the emdef utility:

emdef defcal -u controlm_username -p [password] -HOST [control M_server] -SRC_FILE "./[filename].xml"

Get the xml file we have transfered:

[[email protected] ~]# su - emuser
serveurctmv919% cd /tmp

We can launch the command to import the calendar and then checkinh on the gui if it is appearing:

serveurctmv919% emdef defcal -u emuser -p Sofiane2020 -HOST serveurctmv919 -SRC_FILE "/tmp/CALENDAR_EXAMPLE_1_exported.xml"
File /tmp/CALENDAR_EXAMPLE_1_exported.xml is missing.
serveurctmv919% cat /tmp/CALENDAR_EXAMPLE_1_exported.xml
cat: /tmp/CALENDAR_EXAMPLE_1_exported.xml: acces denied

we have to give the correct rights to grant emuser acces to this file.

You must connect with user root and grant access:

[[email protected] ~]# chown emuser:emgrp /tmp/CALENDAR_EXAMPLE_1_exported.xml
[[email protected] ~]#
serveurctmv919% ls -lart C*
-rwxrwx---. 1 emuser emgrp 676 10 févr. 12:58 CALENDAR_EXAMPLE_1_exported.xml

And then restart the command:
serveurctmv919% emdef defcal -u emuser -p S*****0 -HOST serveurctmv919 -SRC_FILE "/tmp/CALENDAR_EXAMPLE_1_exported.xml"
serveurctmv919% cd /tmp
serveurctmv919% emdef defcal -u emuser -p S*****0 -HOST serveurctmv919 -SRC_FILE "/tmp/CALENDAR_EXAMPLE_1_exported.xml"
2020: Description's length must not exceed 50 characters.
Error parsing XML input file. Exiting...

We get an issue asking us to check about the description length (that was obviously not the case 😈 )

So after checking the number of characters in the description and then investigate in the database tables to check the maximum of characters allowed It appears that the issue didn’t correspond to the message displayed:

The solution to solve this issue was to check again the prerequisites especially the one concerning the datacenter name:

Into the exported file we had:


Whereas our Control M server datacenter is named :

serveurctmv919% ps -eaf | grep gtw
emuser    4907     1  0 14:47 pts/0    00:00:00 /bin/sh /home/emuser/ctm_em/bin/em gtw -dc serveurctmv919

We have to update the xml file with the right datacenter and restart the command:

serveurctmv919% emdef defcal -u emuser -p S*****0 -HOST serveurctmv919 -SRC_FILE "/tmp/CALENDAR_EXAMPLE_1_exported.xml"
Year 2020 is valid
Calendar CALENDAR_EXAMPLE_1 of DataCenter serveurctmv919 is valid
1 calendars were written to CONTROL-M/EM database.

Now we will connect to the GUI of the control M server where we done the calendar import to check if the calendar is available.
As you can see the calendar import was done and he is already uploaded in the database ready to be used.

Conclusion :

Export of the calendar and import are done successfully! This can be useful when you work on many environments that must be ISO with the same schedule but on different clients.


  • Roberto Hermosilla says:

    Hi Nabil! thanks for your all this!
    I need to know if i import calendars and this calendars already exist, are they replaced?

    • Nabil Saoual says:

      Hi Roberto,
      Sorry for the delay I’ve been a little busy lately
      Indeed , if you import the calendar and it has the same name it will overwrite the current one, so if you want to keep the old one you have to give different name.
      When you perform update of your calendars from the GUI don’t forget to upload it.To be sure check the “synchronization” state column if hour and date are corresponding to your import time

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Nabil Saoual
Nabil Saoual