Query a DB and create a file in the project root

I have a script that queries an external database and creates a .csv file. I want to run this script once a day.

Till now I tried to do it with cron jobs, but it’s a different instance than the web service.

Tried with API jobs, and it seems running but does not create a file.

Tried to do it with crontab, but Crontab is not available inside the service.

What is the correct way to do that?

When I run the script in the shell manually it works well. But I don’t want to do it every day and after every build manually.

Hello, have you tried about making a systemd service that has a simple script with an infinite loop and a sleep of 1 day? Just enable it with systemctl enable service if you have systemd in your shell. Also you can customise in which phase of the mount you can enable it by default

Thank you, I will try it if I can not find another solution. I rather do it with Cron jobs or a similar approach.

Hi there,

One alternative would be to store this csv file in an external object storage, like S3. Unless you are using a disk, storing files on the server will use ephemeral storage, and these files will not persist between deploys.

Thank you for your answer. You are right, with object storage the file will not go away between deploys. But I have to renew the file every day. I couldn’t fully understand how I can run a script every 24H to create a file. This is the first thing I need to solve.


If you are storing the file in an external object storage, you should be able to use a cronjob or the jobs API to initiate the file creation.

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