When working in 1C, there are many routine operations that must be launched or formed according to a schedule to perform one or another action, for example: posting documents or loading data into 1C from a website.

I recently posted an article: It's time to automate this:

Routine and background tasks

The job engine is designed to perform any application or functionality on a schedule or asynchronously.

The task mechanism solves the following tasks:

  • Ability to define regulatory procedures at the system configuration stage;
  • Execution of specified actions according to schedule;
  • Making a call to a given procedure or function asynchronously, i.e. without waiting for its completion;
  • Tracking the progress of a specific task and obtaining its completion status (a value indicating whether it was successful or not);
  • Obtaining a list of current tasks;
  • Ability to wait for one or more tasks to complete;
  • Job management (possibility of cancellation, blocking of execution, etc.).

The job mechanism consists of the following components:

  • Metadata of routine tasks;
  • Regular tasks;
  • Background jobs;
  • Task Scheduler.

Background jobs & are designed to perform application tasks asynchronously. Background tasks are implemented using the built-in language.

Scheduled tasks & are designed to perform application tasks on a schedule. Routine tasks are stored in the information base and are created based on metadata defined in the configuration. Metadata of a regulatory task contains information such as name, method, use, etc.

A routine task has a schedule that determines at what times the method associated with the routine task must be executed. The schedule, as a rule, is specified in the information base, but can also be specified at the configuration stage (for example, for predefined routine tasks).

The task scheduler is used to schedule the execution of routine tasks. For each scheduled task, the scheduler periodically checks whether the current date and the time of the routine task schedule. If it matches, the scheduler assigns that task to execution. To do this, for this scheduled task, the scheduler creates a background task, which performs the actual processing.

I think that’s enough with the description - let’s get down to implementation:

Creating a routine task

Method name– path to the procedure that will be executed in a background job according to a given schedule. The procedure must be in a common module. It is recommended not to use standard common modules, but to create your own. Don't forget that background jobs run on the server!

Usage– sign of using a routine task.

Predetermined– indicates whether the routine task is predetermined.

If you want the routine task to work immediately after being placed in the database, specify the attribute Predetermined. Otherwise, you will need to use the “Job Console” processing or trigger the task to run programmatically.

Number of retries when a job terminates abnormally– how many times the background job was restarted if it was executed with an error.

Retry interval when job terminates abnormally– how often the background job will be restarted if it was completed with an error.

Setting up a schedule

Schedule completing the task:

Every hour, just one dayRepeatDays Period = 0, RepeatDays Period = 3600
Every day once a dayRepeatDays Period = 1, RepeatDays Period = 0
One day, one timePeriodRepeatDays = 0
Every other day once a dayPeriodRepeatDays = 2
Every hour from 01.00 to 07.00 every dayPeriodRepeatDays = 1RepeatPeriodDuringDay = 3600StartTime = 01.00

End Time = 07.00

Every Saturday and Sunday at 09.00RepeatDays Period = 1WeekDays = 6, 7StartTime = 09.00
Every day for one week, skip a weekPeriodRepeatDays = 1PeriodWeeks = 2
At 01.00 onceStart Time = 01.00
Last day of every month at 9:00.PeriodRepeatDays = 1DayInMonth = -1StartTime = 09.00
Fifth day of every month at 9:00PeriodRepeatDays = 1DayInMonth = 5StartTime = 09.00
Second Wednesday of every month at 9:00PeriodRepeatDays = 1DayWeekMonth = 2DaysWeek = 3

Start Time = 09.00

Features of executing background jobs in file and client-server variants

The mechanisms for executing background jobs in the file and client-server versions are different.

In file version you need to create a dedicated client process that will perform background jobs. To do this, the client process must periodically call the global context function ExecuteJobProcessing. Only one client process per infobase should process background jobs (and, accordingly, call this function). If a client process has not been created to process background jobs, then when programmatically accessing the job engine, the error “Job Manager is not active” will be displayed. It is not recommended to use a client process that processes background jobs for other functions.

Once the client process processing background jobs has started, other client processes can software access to the mechanism of background jobs, i.e. can run and manage background jobs.

In client-server version To execute background jobs, a task scheduler is used, which is physically located in the cluster manager. For all queued background jobs, the scheduler gets the least loaded worker process and uses it to run the corresponding background job. The worker process executes the job and notifies the scheduler of the execution results.

In the client-server version, it is possible to block the execution of routine tasks. The execution of routine tasks is blocked in the following cases:

  • An explicit blocking of routine tasks has been installed on the information base. The lock can be set via the cluster console;
  • There is a connection block on the infobase. The lock can be set via the cluster console;
  • The SetExclusiveMode() method with the True parameter was called from the built-in language;
  • In some other cases (for example, when updating the database configuration).

Processing the launch and viewing of scheduled tasks you can download here.

In this article I will talk about how to add new or existing databases to the 1C:Enterprise server. 8.3 (for other versions of the platform - 8.1 And 8.2 actions are similar). Options for adding will be considered information base both from and through the 1C:Enterprise server administration program (in Windows OS). Some issues of administering information bases in a 1C:Enterprise server cluster are also touched upon.

1. Adding an infobase from the 1C:Enterprise launch window

Let's create a new database on the 1C:Enterprise server from a standard configuration. To do this, launch “1C:Enterprise” and in the launch window click “ Add…» to add an information base.

The wizard for adding an information base will start, select the item “ Creation of a new information base" by setting the appropriate switch and clicking " Next».

In the list of installed configuration templates, select the template we need and click “ Next».

Let's enter the name of the database as it will be displayed in the list of infobases, specify the location type " On the 1C:Enterprise server" and click " Next».

On the next page you need to specify the parameters of the created infobase, namely:

(IN in this example parameters were selected in accordance with the 1C:Enterprise server installation parameters adopted in the article)

  • Server cluster name 1C:Enterprise— as a rule, it matches the network name of the computer where the 1C:Enterprise server is installed (the central cluster of the server);
  • Name of the database being created in the cluster— the name by which the information base will be accessed. Must be unique within a given cluster;
  • Secure connection- disabled by default;
  • Type of DBMS on which the database will be stored— in this example, MS SQL Server;
  • Database server name— as a rule, it consists of the network name of the computer where the database server is installed and the name of the server instance (if any), separated by the “\” sign;
  • Name of the database on the database server— for convenience, we will adhere to the rule that the name of the database must match the name of the infobase in the cluster. In addition, in the case of using MS SQL Server, the first character in the database name can only be a letter of the Latin alphabet or the symbol “_”, subsequent characters can only be a letter of the Latin alphabet, a number or the symbols “_” and “&”, the name must be unique within a given database server instance and not exceed 63 characters. If the database already exists on the server, the current database will be used, if not and the flag " Create a database if it doesn't exist", a new database will be added to the database server.
  • Database user— a DBMS user who will become the owner of the database on the server if a new database is created or who has rights to work with an existing one;
  • User password— the password of the user on whose behalf the database will be accessed;
  • Date offset- 0 or 2000. This parameter defines the number of years that will be added to dates when they are saved in the database Microsoft data SQL Server and subtracted when retrieving them. The fact is that the DATATIME type used by Microsoft SQL Server allows you to store dates in the range from January 1, 1753 to December 31, 9999. If, when working with an infobase, there may be a need to store dates preceding the lower limit of this range, the date offset should be selected as 2000. In addition, if the application solution uses accumulation registers or accounting registers (and most likely this will be the case), also in the “field date offset must be set to 2000.
  • Set blocking of scheduled tasks— setting the flag allows you to prohibit the execution of scheduled tasks on the server for this information base. It should be installed in the case of creating test information bases, where the implementation of routine tasks does not carry any practical load.

Having set all the information base parameters, click “ Next».

And finally, specify the launch parameters for the database being created and click “ Ready» to start the process of creating a new information base. At the same time, a new information base will be created on the 1C:Enterprise server, if necessary, created new base data on the database server, and data will also be loaded from the configuration template.

If all of the above actions are completed successfully, the wizard will complete its work, and we will see the newly created database in the list of infobases in the 1C:Enterprise launch window.

2. Adding an information base from the 1C:Enterprise server administration console

Now let’s add another infobase to the server cluster, but through the “ Administration of 1C:Enterprise servers"(previously). You can find it:

Well, in any case, the snap-in can be launched by executing the file “ 1CV8 Servers.msc"located in the 1C:Enterprise installation directory in the subdirectory " common».

If the equipment " " is launched on the same computer where the 1C:Enterprise server is installed, then in the tree on the left, in the branch with the network name of the current computer, we should see this cluster of servers called " Local cluster" Expanding the tab " Information bases"we will see all the infobases in this server cluster (for example, the database created through the 1C:Enterprise launch window in the previous step). To add a new information base, click right click mouse on this tab, in context menu select " Create» — « Information base».

The parameters window for the created infobase will open. The list of parameters is the same as that described above in paragraph 1 of this instruction. After filling out all the parameters, click “ OK» to start the process of creating a new information base. In this case, a new information base will be created on the 1C:Enterprise server and, if necessary, a new database will be created on the database server.

If all of the above actions are completed successfully, the parameters window will close, and we will see the newly created database in the list of infobases of the current cluster.

And if you go to the “Wednesday” program SQL Server Management Studio" and connect to the current instance of MS SQL Server, you can see the databases created in the previous steps.

3. Properties of the infobase

To view or change the parameters of a specific infobase, you need to use the " Administration of 1C Enterprise servers", in the list of infobases, right-click on it and select " Properties" To authenticate in the administration console, you must use administrators in the corresponding infobases. In other words this check is similar to authentication when connecting to an infobase through the 1C:Enterprise client.

As you can see, the following have been added to the list of parameters already familiar to us:

  • Session start blocking is enabled— a flag that allows you to enable blocking of the start of sessions with the infobase; if the flag is set, then:
    • Existing sessions can continue running, establish new connections, and also run background jobs;
    • Establishing new sessions and connections to the infobase is prohibited.
  • Start And End— duration of session blocking;
  • Message— text that will be part of the error message when trying to establish a connection with a blocked infobase;
  • Permission code— the string that should be added to the parameter /UC when starting 1C:Enterprise to connect to the infobase despite being blocked;
  • Blocking options— arbitrary text that can be used in configurations for various purposes;
  • External session management— a string describing the parameters of the Web service external control sessions;
  • Mandatory use of external control— if the flag is set, then if the external session management Web service is unavailable, an error occurs and establishing a connection to the infobase is impossible;
  • Security Profile— if you specify a profile name, the application solution begins to work taking into account the restrictions imposed by the specified security profile;
  • Security Profile safe mode - the same as the security profile, but restrictions will be imposed on fragments of the application solution operating in safe mode.

After changing the necessary parameters, click “ Apply" to save changes or " OK» to save and close the infobase properties window.

4. Adding an existing infobase to the list of infobases in the 1C:Enterprise launch window

And finally, all we have to do is add the one created using the “ Administration of 1C Enterprise servers» infobase to the list of infobases in the 1C:Enterprise launch window. Why in this window click “ Add…" and in the wizard that starts adding an infobase/group, select the appropriate item and click " Next».

Enter the name of the infobase as it will be displayed in the list, select the type of infobase location " On the 1C:Enterprise server" and press " again Next».

Enter the address of the 1C:Enterprise server cluster and the name of the infobase, as it is defined in this cluster. Click " Next».

And finally, set the parameters for launching the infobase and click “ Ready» to complete the wizard.

Our database has appeared in the list of information databases. You need to understand that this is an empty (clean) database, and then you should load data into it from a template, or from a pre-loaded data file.

Did this article help you?

How to speed up work in 1C: Accounting 8.3 (edition 3.0) or disable routine and background tasks

2019-01-15T13:28:19+00:00

Those of you who have already switched to the new edition of 1C: Accounting 8.3 (edition 3.0) have noticed that it has become slower than 2. Some strange slowdowns, endless background tasks several times a day, which no one asked her to perform without our knowledge.

My accountants told me immediately after the transition that the new edition of 1C: Accounting 3.0 is downright slow compared to the previous ones! And it’s simply impossible to work.

I started looking into it and very soon found out that the main cause of freezes and subsequent user dissatisfaction are routine and background tasks, many of which are enabled by default, although for the vast majority of accountants there is no need for them.

Well, for example, why do we need to run the “Text Extraction” task a hundred times a day if we do not perform a full-text (accountants, don’t be alarmed) search across all objects in our database.

Or why constantly download currency rates if we do not have currency transactions or we do them occasionally (and before that we ourselves can click the download rates button).

The same applies to 1C’s constant attempt to connect to the site and check and update bank classifiers. For what? I myself will press the button to update the classifiers if I don’t find the right bank by its BIC.

How to do this step by step below.

1. Go to the "Administration" section and select "Maintenance" () in the action panel:

2. In the window that opens, find and select “Routine and background tasks”:

3. Open each task that has "On" in the "On" column. there is a daw.

4. Uncheck "Enabled" and click the "Save and Close" button.

5. Do this with each of the included tasks and enjoy the new edition. Overall, in my opinion, it is much better than two.

At the same time, the platform will still enable some of the scheduled tasks you disabled.

Allows us to perform any calculations in the system unnoticed by the user, that is, in the background. Moreover this mechanism allows us to parallelize the calculation process. We can even parallelize the procedure that will be executed. To do this, our background job must run several more background jobs. In this case, the processes are parallelized and, if we have a multiprocessor, multi-core system, our algorithm will work efficiently. After launching several processes, we can tell the system that it needs to wait for the completion of these processes in order to somehow combine the result.

For example, in typical configurations, while the user is working, various kinds of background service jobs are executed. This can be evidenced by log entries that record the fact that such actions were performed. Moreover, this does not affect the user’s work in any way, he simply does not notice them.

Ideally, a background job is implemented in a client-server version, in which case the entire load goes to the server. As for the file option, a background job is possible, but it has some peculiarities.

This is what the system will produce if you do not take these features into account and run a background job in the file version of the infobase.


The 1C background job has some limitations. Since it is executed on the server side, there is no possibility of interactive work with the user. For example, you cannot display a message, or any information at all. All this data needs to be stored within the information base and further processed in some way.
By contacting the syntax assistant, you can get more detailed information about 1C background jobs. It should be noted here that this object is purely software and is not stored in the database in any way. That is, we create an instance of the class, initialize the properties and launch it for execution.

What tools do we have to manage background jobs? This facility is a metadata object "BackgroundTask Manager". This object has a method "Run", using this method, the background job is launched.

It has the following parameters:
"MethodName"- the name of the procedure or function to be executed, and it must be a procedure or function of the server context;

"Options"- an array of parameters, the number of elements of which must correspond to the number of parameters of our procedure/function specified in the parameter "MethodName";

"Key"- a certain uniqueness key, which is a line by which the system understands whether a background task needs to be launched or whether such a task is already running;

"Name"- here you can specify an arbitrary description of our method.

The return value is an object "BackgroundTask", containing the current method name, the current key, and several more properties and methods. One such method is the method "WaitComplete". Its purpose is that we can tell the system not to do anything until the background job is completed.

Background job 1C 8.2, 8.3 - Example of use

Let's give an example of working with 1C background jobs. First, we will create a simple algorithm that will briefly load the 1C system in such a way that we cannot do anything at this time.

To do this:

1. Let's create a common module "BackgroundTask Handlers", which will be compiled on the server side;


2. We will describe the export procedure in it "ProduceBackgroundCalculation(Parameter)", which takes one parameter of string type;

Procedure PerformBackgroundCalculation(Parameter) ExportStartTime = CurrentDate() ; While CurrentDate() - Start Time< = 6 Цикл КонецЦикла ; КонецПроцедуры Процедура КнНажатие() ОбработчикиФоновыхЗаданий. ПроизветиФоновоеВычисление("Some parameter") ; End of Procedure
Ready. Now, when you start processing and press a button, the system freezes for several seconds, during which nothing can be done. This is exactly what we needed to do.

Now we will ensure that these calculations are carried out in the background, that is, so that the background task 1C 8.2, 8.3 is executed, but does not interfere with us.

To do this:

1. In processing, in the button click event, write the following code.

Procedure KnPress() Parameters = New Array; Options. Add( "Some parameter") ; BackgroundTask. Run ( "BackgroundTask Handlers. Perform BackgroundComputation", Parameters, New UniqueIdentifier, "Test task") ; End of Procedure

Here we pass the name of the common module procedure as the first parameter, and an array of parameters as the second. The third parameter needs to be passed a unique key and the fourth parameter some description of our procedure.

Users often complain that “1C 8.3 is slow”: document forms open slowly, documents take a long time to process, the program starts, reports take a long time to generate, and so on.

Moreover, such “glitches” can occur in different programs:

The reasons may be different. This is not restored documents, a weak computer or server, the 1C server is incorrectly configured.

In this article I want to look at one of the simplest and most common reasons for a slow program - . This instruction will be relevant for users of file databases for 1-2 users, where there is no competition for resources.

If you are interested in more serious optimization of client-server options for system operation, visit the section of the site.

Where are the scheduled tasks in 1C 8.3?

Before I had time to load the program, many background tasks were completed in 1C. You can view them by going to the “Administration” menu, then “Support and Maintenance”:

Get 267 video lessons on 1C for free:

This is what the window with completed tasks looks like:

And so full list all scheduled tasks that are launched:

Among these tasks you can see such as ““, loading various classifiers, checking the relevance of the program version, and so on. For example, I have no use for almost all of these tasks. I don’t keep currency records, I control the versions myself, and load classifiers as needed.

Accordingly, it is in my (and in most cases in your) interests to disable unnecessary tasks.

Disabling scheduled and background tasks in 1C 8.3