Drone Cron Job Not Firing - cron

I've created a cron job in Drone CI using the following command
drone cron add --branch master "foo/bar" "every-5-mins" "0 */5 * * * *"
And when I look in the UI, I can see the cron job has been created. However, it doesn't fire, even though I have it defined in my drone yaml file.
- name: cron-job
pull: if-not-exists
image: foo-image
commands:
- *random
- echo "I am testing a cron job"
when: &cron-demo
event:
- cron
cron:
- every-5-mins
Does something else need to be done to get it to work on schedule?
And also, is there a way to manually trigger a cron job? I can't seem to find anything in the docs.

You might find this helpful.
https://docs.drone.io/api/cron/cron_trigger/
Basically, what you need is something like this.
curl -X POST -H "Authorization: Bearer $DRONE_TOKEN" "$DRONE_SERVER/api/repos/foo/bar/cron/every-5-mins"

Related

Running multiple commands in the same cron job using Ansible

I currently have a cronjob that creates a backup of a postgres db in ansible
- name: Create a cron job to export database.
become_user: postgres
cron:
name: "Export database"
minute: "*/2"
job: "pg_dump -U postgres -W -F t db_name > db_backup-$(date +%Y-%m-%d-%H.%M.%S).tar"
I want to run a gsutil cp command in the same job that then uploads this backup to a storage location in GCP.
I understand that with a cronjob you would simply separate the two jobs with && however I'm not sure how this would work in ansible.
Any pointers would be great, thank you!
What you put in the job attribute will end up in the crontab. (You can check this with crontab -l on the machine).
So you can do everything in ansible, you could do on the crontab directly, including chaining multiple commands separated by && or ;.
If you have a very long line here, I'd suggest to write a script and have cron execute that for readability reasons.

Cron job creating files each time it runs

I have a cron job that runs the script every 30 minutes. The problem is each time it runs the cron it creates a file in the root directory. It'll create files like this:
wp-cron.php?doing_wp_cron.1
wp-cron.php?doing_wp_cron.2
wp-cron.php?doing_wp_cron.3
This is my cron:
*/30 * * * * wget http://yourdomain.com/wp-cron.php?doing_wp_cron 2>&1 > /dev/null
How can I make it auto delete after it finishes running the cron job or make it not create the file?
wget primarily is for downloading files, it might be better to use curl
curl http://yourdomain.com/wp-cron.php?doing_wp_cron

How do I make AcySms manual cron job in cPanel work?

When setting up AcySMS, there are few option for the cron job. "Web cron" runs at the fastest interval of 15 minutes, way too slow for me.
I have opted for "manual cron", and am given the following "cron URL" https://www.followmetrading.com/index.php?option=com_acysms&ctrl=cron
Putting that into the cPanel cron job manager just leaves me with an error everytime the cron attempts to run:
/usr/local/cpanel/bin/jailshell: http://www.followmetrading.com/index.php?option=com_acysms: No such file or directory
I have discovered that the following command executes the script properly.
curl --request GET 'https://www.followmetrading.com/index.php?option=com_acysms&ctrl=cron&no_html=1' >/dev/null 2>&1
Note: ensure the URL is surrounded by ' ' otherwise it seems to miss everything from the & onward.
Note: >/dev/null 2>&1 makes sure there is no email trail.

How to set up a Cron job?

I am trying to set up Recurring Invoices as documented on http://www.fusioninvoice.com/support/recurring-invoices but I don't understand and cant work out what to do.
I have found a alphanumeric 'key' but not sure where or what to do?
Do I need to createa file or something?
If curl is available on your system, you can schedule it to ping the URL.
Use crontab -e to edit the cron table and create a new entry. For example, this will ping the URL every day at midnight.
0 0 * * * /usr/bin/curl --silent http://your-server.com/index.php/invoices/cron/recur/your-cron-key-here &>/dev/null

Cron Job Commands not working

I am new to cron jobs and have set up one in Plesk to execute every minute however I am not sure if the command is correct due to it not working.
curl http://www.yourdomain.com/twitter_cron.php
I am running on a Centos VPS - the problem is I am not sure if I need a specific root to curl.
sgeorge-mn:~ sgeorge$ which curl
/usr/bin/curl
You need to use full path in cron for curl; otherwise you need to have proper PATH variable specified in crontab
So for example:
* * * * * /usr/bin/curl http://www.yourdomain.com/twitter_cron.php

Resources