# Using an asynchronous task | Creating UCS File

**URL:** <https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322>\
**Category:** Technical Forums\
**Tags:** big-ip, super-netops, ltm\
**Created:** [July 18, 2019, 3:45pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322 "2019-07-18T15:45:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julio\_Navarro](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Julio\_Navarro](https://community.f5.com/u/Julio_Navarro)\
**Post date:** [July 18, 2019, 3:45pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/1 "2019-07-18T15:45:38Z")

</div>

Hi,

I am trying the following REST URL to create a task to generate a UCS File:

```tcl
Method: Post
URI: mgmt/tm/task/sys/ucs/
Body: { "command": "save",    "name": "UCS01" }

```

So, I get back:

```tcl
{
  "_taskId": 1563464422689504,
  "_taskState": "STARTED",
  "_taskTimeInStateMs": 0,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504/result?ver=12.1.3.4",
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504?ver=12.1.3.4"
}

```

Now, when I do check the status:

```tcl
Method: Get
URI: /mgmt/tm/task/sys/ucs/1563464422689504

```

I gel back:

```tcl
{
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504?ver=12.1.3.4",
  "_taskId": 1563464422689504,
  "_taskState": "COMPLETED",
  "_taskTimeInStateMs": 5000,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563464422689504/result?ver=12.1.3.4"
}

```

When I go to _/var/local/ucs,_ I don’t see the UCS created.

_\*\* Maybe I am missing something. Please advise \*\*_

_----------- If I don’t use the “task” option, then it will worked. But I would like to use the task option to take advantage of asynchronous tasks ----_

Thank you

---

<div class="post-metadata">

**Author:** ![cjunior](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@cjunior](https://community.f5.com/u/cjunior)\
**Post date:** [July 18, 2019, 5:32pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/2 "2019-07-18T17:32:58Z")

</div>

Hi,

Tested on v15.0.0 looks OK for me.

What BIG-IP version are you trying to?

```tcl
curl -k -u admin:admin -X POST -H 'Content-Type: application/json' -d '{ "command": "save", "name": "UCS01" }' https://localhost/mgmt/tm/task/sys/ucs
 
{
  "_taskId": 1563470408202544,
  "_taskState": "STARTED",
  "_taskTimeInStateMs": 0,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544/result?ver=15.0.0",
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544?ver=15.0.0"
}

```

```tcl
curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' https://localhost/mgmt/tm/task/sys/ucs/1563470408202544
 
{
  "code": 202,
  "message": "Task will execute asynchronously.",
  "errorStack": []
}

```

```tcl
curl -k -u admin:admin https://localhost/mgmt/tm/task/sys/ucs/1563470408202544
 
{
  "selfLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544?ver=15.0.0",
  "_taskId": 1563470408202544,
  "_taskState": "COMPLETED",
  "_taskTimeInStateMs": 13000,
  "_taskResultLink": "https://localhost/mgmt/tm/task/sys/ucs/1563470408202544/result?ver=15.0.0"
}

```

```tcl
# ls -la /var/local/ucs
total 484520
drwxr-xr-x. 3 root root 4096 Jul 18 14:29 .
drwxr-xr-x. 9 root root 4096 Jun 28 12:23 ..
-rw-r--r--. 1 root root 195341011 Jun 28 12:23 config.ucs
-r--r--r--. 1 root root 114 May 10 05:57 cs_backup_rotate.conf
drwxr-xr-x. 2 root root 4096 Jun 28 12:43 tmp
-rw-r--r--. 1 root root 300789664 Jul 18 14:15 UCS01.ucs
 

```

---

<div class="post-metadata">

**Author:** ![Julio\_Navarro](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Julio\_Navarro](https://community.f5.com/u/Julio_Navarro)\
**Post date:** [July 18, 2019, 6:53pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/3 "2019-07-18T18:53:21Z")

</div>

Hi, we are on version 12.1.3.4

---

<div class="post-metadata">

**Author:** ![cjunior](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@cjunior](https://community.f5.com/u/cjunior)\
**Post date:** [July 18, 2019, 8:23pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/4 "2019-07-18T20:23:02Z")

</div>

Buddy, It works for me on v12.1.3.4.

```tcl
# curl -k -u admin:admin -X POST -H 'Content-Type: application/json' -d '{ "command": "save", "name": "UCS01" }' https://localhost/mgmt/tm/task/sys/ucs
{
    "_taskId":1563478591515657,
    "_taskState":"STARTED",
    "_taskTimeInStateMs":0,
    "_taskResultLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657/result?ver=12.1.3.4",
    "selfLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4"
}
 
# curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4
{
    "code":202,
    "message":"Task will execute asynchronously.",
    "errorStack":[]
}
 
# curl -k -u admin:admin https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4
{
    "selfLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4",
    "_taskId":1563478591515657,
    "_taskState":"COMPLETED",
    "_taskTimeInStateMs":10000,
    "_taskResultLink":"https://localhost/mgmt/tm/task/sys/ucs/1563478591515657/result?ver=12.1.3.4"
}
 
 
# ls -la /var/local/ucs
total 3976
drwxr-xr-x. 3 root root 4096 2019-07-18 12:37 .
drwxr-xr-x. 9 root root 4096 2019-07-18 12:20 ..
-r--r--r--. 1 root root 114 2018-04-10 13:52 cs_backup_rotate.conf
drwxr-xr-x. 2 root root 4096 2019-07-18 12:22 tmp
-rw-r--r--. 1 root root 4049809 2019-07-18 12:37 UCS01.ucs

```

So, if you can save UCS from another way, we can’t confirm issues during save the file.

It sounds strange to me 😞

---

<div class="post-metadata">

**Author:** ![Jason\_Adams](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jason_adams/32/3658_2.png) [@Jason\_Adams](https://community.f5.com/u/Jason_Adams)\
**Post date:** [April 24, 2020, 3:38pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/5 "2020-04-24T15:38:22Z")

</div>

; to close the loop on this one, it appears that you the part that was missing in your request is the -X PUT request, to set the state to ‘VALIDATING’

```tcl
# curl -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"_taskState":"VALIDATING"}' <a href="https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4" target="_blank" rel="nofollow noopener noreferrer">https://localhost/mgmt/tm/task/sys/ucs/1563478591515657?ver=12.1.3.4</a>
{
    "code":202,
    "message":"Task will execute asynchronously.",
    "errorStack":[]
}

```

That is the request which is necessary to cause any task to begin processing. Until then, the task is waiting for any number of additional tasks to be added together.

---

<div class="post-metadata">

**Author:** ![Julio\_Navarro](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Julio\_Navarro](https://community.f5.com/u/Julio_Navarro)\
**Post date:** [April 24, 2020, 7:42pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/6 "2020-04-24T19:42:04Z")

</div>

And you are right! Thank you.

---

<div class="post-metadata">

**Author:** ![Roman\_Melekh](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@Roman\_Melekh](https://community.f5.com/u/Roman_Melekh)\
**Post date:** [May 19, 2023, 2:32pm UTC](https://community.f5.com/t/using-an-asynchronous-task-creating-ucs-file/62322/7 "2023-05-19T14:32:38Z")

</div>

Hello

It looks like I need somebody’s help to determine what could be wrong with my script.

I am re-writing all the logic using PowerShell, but the idea is the same - to create a task, to start the task, to check if the task state is COMPLETED and then to download the result.

Here is what I am facing:

step1, to create a task:

```json
_taskId : 1684506387897122
_taskState : STARTED
_taskTimeInStateMs : 0
_taskResultLink : https://localhost/mgmt/tm/task/sys/ucs/1684506387897122/result?ver=16.1.3.4
selfLink : https://localhost/mgmt/tm/task/sys/ucs/1684506387897122?ver=16.1.3.4

```

step2, to start the task

```json
code : 202
message : Task will execute asynchronously.
errorStack : {}

```

step3, getting status (the request hags for ~30 seconds):

```powershell
Invoke-RestMethod : {"code":400,"message":"remoteSender:10.0.3.138, method:GET ","referer":"10.0.3.138","restOperationId":15296221,"kind":":resterrorresponse"}

```

If I request status for the 2nd time, I can get (sometimes) task COMPLETED, or I can get a “Task not found” error. My question is why do sometimes tasks disappear?
