Reach Disk from running from jobs

Hi Render community.

I want schedule some work, and result save in disk. Because disk can’t be shared by CRON service and Web Service I decide to do following.

In my Phython project I created file schedule.py and was trying to run by calling jobs endpoint

import requests

url = "https://api.render.com/v1/services/srv-***/jobs"

payload = {"startCommand": "python schedule.py"}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": "Bearer ***"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

service is running, but file is not saved.

this is my schedule.py

from datetime import datetime

# Get current date
current_date = datetime.now()

# Convert to string
date_str = current_date.strftime('%Y-%m-%d')

# Write to file
with open('/var/data/current_date.txt', 'w') as file:
    file.write(date_str)

any ideas why this is happening? P.S. if I’ll save data from endpoint everything works, but when schedule.py is runned as Jobs, something is wrong. maybe Disk is not available for Jobs as well because it’s virtual environment?

Hi there,

Disks can only be attached to a single instance at a time. This is why autoscaling is disabled when a disk is involved - so similar to webservices and cronjobs, a job can’t access the disk either - a job is an isolated instance of your service.

Worth upvoting a few of the feedback requests we’ve had around this:

https://feedback.render.com/features/p/disks-for-cron-jobs
https://feedback.render.com/features/p/allow-disk-access-from-multiple-instances-and-services

John B
Render Support, UTC+1 :uk:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.