I would like to set up periodic jobs on an Amazon Lightsail instance, but I can find no information on it - only for Amazon EC2.
Is it possible to issue cron jobs on a l
To answer my own question, just 8 hours later: It IS possible to issue cron jobs on Amazon Lightsail instances
Here is a working example of running a PHP script:
Create a folder called 'projects' in /home/bitnami/ and create a simple .php file called Hello World:
Use command crontab -e
to access a document, from where you can add lines that will be your scheduled cron jobs.
Append two lines to the document AND ADD A NEWLINE:
PATH=/usr/bin:/bin:/opt/bitnami/php/bin:
* * * * * php -f /home/bitnami/projects/HelloWorld.php > /home/bitnami/projects/Out.put
Line 1 adds php to the cron path (Cron sees a different path than what is given in the environment variables. Type: env and hit enter in the console). To see which env variables are given to cron replace line 2 with: * * * * * env > /tmp/env.output
and look in the file. Line 2 is the cron schedule. The asterisks means: Do this every minute of every hour, day, month, year. Search Google for this :) And will output to a file called Out.put
.
Wait 1 minute and see that Out.put
has been created and contains the magic words of Hello World
If you are having problems with cron jobs not working, check out this troubleshooting guide: https://stackoverflow.com/tags/cron/info
Hope this helps. If it does not, post a comment before downvoting!