Odd Cron format doesn't appear to be interpreted properly
So, I've got a niche (or at least from a cron perspective) use case that I need to run a playbook on every first monday of the month.
I found this article which talks about how you can override the default behavior in cron to do this. So, I set the cron in semaphore to be: 0 5 */100,1-7 * MON
Unfortunately it seems like semaphore isn't interpreting that syntax correctly, because it just ran on this past monday instead of 2023-03-06 05:00:00.
It looks like it accepted the string properly when I dump out the schedule table in the web-ui & DB:
web-ui:

DB:
> select * from project__schedule where project_id = 1 AND template_id = 13;
+----+-------------+------------+---------------------+---------------+------------------+
| id | template_id | project_id | cron_format | repository_id | last_commit_hash |
+----+-------------+------------+---------------------+---------------+------------------+
| 2 | 13 | 1 | 0 5 */100,1-7 * MON | NULL | NULL |
+----+-------------+------------+---------------------+---------------+------------------+
This was the event table:
> select * from event where id > 1030 and id < 1045;
| 1037 | 1 | 192 | task | Task ID 192 queued for running | 2023-02-20 05:00:01 | NULL |
| 1038 | 1 | 192 | task | Task ID 192 (Monthly Updates - <REDACTED>) is preparing | 2023-02-20 05:00:01 | NULL |
| 1039 | 1 | 192 | task | Task ID 192 (Monthly Updates - <REDACTED>) finished - WAITING | 2023-02-20 05:00:09 | NULL |
| 1040 | 1 | 192 | task | Task ID 192 (Monthly Updates - <REDACTED>) is running | 2023-02-20 05:00:11 | NULL |
| 1041 | 1 | 192 | task | Task ID 192 (Monthly Updates - <REDACTED>) finished - ERROR | 2023-02-20 06:01:17 | NULL |
I also looked at the systemd log and didn't see anything in there between those time:
# journalctl -eu semaphore --since "2023-02-20 04:00:01" --until "2023-02-20 07:01:17" --output=cat --no-pager
time="2023-02-20T05:00:00Z" level=info msg="Task 192 added to queue"
time="2023-02-20T05:00:01Z" level=info msg="Set resource locker with TaskRunner 192"
time="2023-02-20T05:00:08Z" level=info msg="Stopped preparing TaskRunner 192"
time="2023-02-20T05:00:08Z" level=info msg="Release resource locker with TaskRunner 192"
time="2023-02-20T05:00:11Z" level=info msg="Set resource locker with TaskRunner 192"
time="2023-02-20T05:00:11Z" level=info msg="Task 192 removed from queue"
time="2023-02-20T06:01:17Z" level=info msg="Stopped running TaskRunner 192"
time="2023-02-20T06:01:17Z" level=info msg="Release resource locker with TaskRunner 192"
Is there some other places I should look for errors or issues?
Please let me know if I can help in any other way.
While this shouldn't matter here is some more info on the setup:
- Server: AWS Ubuntu 22.04 EC2 instance
- DB: AWS RDS MySQL 5.7
- Semaphore Service: running as systemd service
# /etc/systemd/system/semaphore.service [Unit] Description=Semaphore Ansible Documentation=https://github.com/ansible-semaphore/semaphore Wants=network-online.target After=network-online.target [Service] Type=simple ExecReload=/bin/kill -HUP $MAINPID ExecStart=/usr/local/sbin/semaphore service --config=/etc/semaphore.json SyslogIdentifier=semaphore Restart=always [Install] WantedBy=multi-user.target - config
{
"mysql": {
"host": "<REDACTED>",
"user": "<REDACTED>",
"pass": "<REDACTED>",
"name": "<REDACTED>",
"options": null
},
"bolt": {
"host": "",
"user": "",
"pass": "",
"name": "",
"options": null
},
"postgres": {
"host": "",
"user": "",
"pass": "",
"name": "",
"options": null
},
"dialect": "mysql",
"port": "",
"interface": "",
"tmp_path": "/opt/ansible",
"cookie_hash": "<REDACTED>",
"cookie_encryption": "<REDACTED>",
"access_key_encryption": "<REDACTED>",
"email_sender": "",
"email_host": "",
"email_port": "",
"email_username": "",
"email_password": "",
"web_host": "",
"ldap_binddn": "",
"ldap_bindpassword": "",
"ldap_server": "",
"ldap_searchdn": "",
"ldap_searchfilter": "",
"ldap_mappings": {
"dn": "",
"mail": "",
"uid": "",
"cn": ""
},
"telegram_chat": "",
"telegram_token": "",
"slack_url": "<REDACTED>",
"max_parallel_tasks": 0,
"email_alert": false,
"email_secure": false,
"telegram_alert": false,
"slack_alert": true,
"ldap_enable": false,
"ldap_needtls": false,
"ssh_config_path": "",
"demo_mode": false
}
Hi, Semaphore uses the Go library robfig/cron to handle cron jobs. When setting up cron schedules you have a little tooltip linking you to this package's supported cron formats (see here).
So it appears that you are trying to use a cron format unsupported by this library.
You may want to test a newer Version Cron and Schedules got improved.
You may want to test a newer Version Cron and Schedules got improved.
Nope, same dead github project is still being used for cron in the latest version. Schedules like "0 0 * * 1#1" and "0 0 * * 5L" still won't work.