execute doctl using cronjob + shell script failed

i have this following code to make droplets (and another shell script code to destroy this droplets), I want to cron this code on the cronjob but failed, can anyone tell me how to cron doctl?

#set environtment variable

#create readonly
echo "create readonly on ${database_id}"
for i in {1..10}
        echo "create db-ro-${i}"
        doctl database replica create $database_id db-ro-$i --size db-s-4vcpu-8gb --region $region

#resizing database
doctl databases resize $database_id --num-nodes $num_nodes --size $size  -v

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 27, 2022
Accepted Answer

Hi there,

When running scripts from a corn job, you need to make sure that you reference files with their full paths.

I believe that you just need to change this line here:


To include the full path to your config directory, eg:


Let me know how it goes.



Site Moderator
Site Moderator badge
November 28, 2022

Hi @sleepingseagreenmorel,

You need to use full paths in your scripts rather than relative ones. This could be a problem for the system as it can detect different paths and thus provide different outcomes.

In your case

#set environtment variable

The database_id should have the full path.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel