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?