How do I use a virtual machine? I have created a droplet and now I want to code in python and have the machine run on its own. Lets say at 12pm everyday I want it run a function and save the result to my local hard drive, how do I do this?
Thanks.
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!
Hi, you’ve described a common use case for cron, a common facility on unix/linux. Here’s a tutorial on setting up cron, including how to set the time and save the result to a hard drive - either as a new file or appending an existing file:
How To Use Cron To Automate Tasks On a VPS
More handy info and a crontab generator app here, too: https://crontab.guru/#0_12_*_*_*
That’s the link for an example crontab setting that will execute every day at 12:00 server time.
Hope this helps - let us know if you have any more questions.
Heya,
To achieve your goal of running a Python function daily at 12 PM on a DigitalOcean Droplet (a virtual machine), and then saving the result to your local hard drive, you’ll need to set up a few things both on your Droplet and your local machine.
In order for your Droplet to execute your script it should be located on it’s hard disk.
You can either transfer it using scp or just create a new file and paste the contents of your script in it.
sudo apt update
sudo apt install cron
crontab -e
Add the following line to run your script daily at 12 PM server time:
0 12 * * * /usr/bin/python3 /path/to/your/task.py
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.