sed replace quoting (server.crontab fails to update crontab entry sometimes)
See original GitHub issueDescribe the bug
I have a feeling this is caused by the cron_name
param. Basically, if I modify the command
param for server.crontab
but leave cron_name
as is, when the deploy is run, it will consider the task to already be present resulting in a no-op.
To Reproduce
- Run on host:
crontab -r
- Run the below deploy once and verify the crontab updated.
- Change the command, and run the below deploy again.
- The crontab will not have been updated.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Deploy to illustrate crontab bug.
"""
###############################################################################
# Imports
###############################################################################
# ==Site-Packages==
from pyinfra.operations import server
###############################################################################
# Main
###############################################################################
server.crontab(
name="Install test cron task.",
command="echo 'banana'",
# command="echo 'yummy'",
cron_name="My special task",
minute="*/10",
)
Expected behavior The crontab should be updated to reflect the changes to the command.
Meta
❯ pyinfra --support
--> Support information:
If you are having issues with pyinfra or wish to make feature requests, please
check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
When adding an issue, be sure to include the following:
System: Darwin
Platform: macOS-10.14.6-x86_64-i386-64bit
Release: 18.7.0
Machine: x86_64
pyinfra: v1.3.6
Executable: /Users/----/.virtualenvs/05-hz-pyinfra-d0Faa_8y-py3.9/bin/pyinfra
Python: 3.9.1 (CPython, Clang 10.0.1 (clang-1001.0.46.4))
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Why is my crontab not working, and how can I troubleshoot it?
A frequent problem users make with crontab entries is that they forget that cron runs in a different environment than they do as...
Read more >CronJob not running - Stack Overflow
Another reason crontab will fail: Special handling of the % character. From the manual file: The entire command portion of the line, up...
Read more >Linux / UNIX Change Crontab Email Settings ( MAILTO )
Explains how to set the MAILTO variable under Linux/Unix cron daemon to send emails to a specific user and change crontab email settings....
Read more >Linux crontab -- which shell am I using - Unix Stack Exchange
2. Possible duplicate of How to change cron shell (sh to bash)? · 1. Incidentally, bash supports >& , so if this is...
Read more >Cron Jobs: A Comprehensive Guide - SitePoint
Active lines in a crontab are either the declaration of an environment variable or a cron job. Crontab does not allow comments on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Figured this out!
The example code is now working in my tests 😃
Nice spot @taranlu-houzz, little bug in checking the command when using
cron_name
, fixed in https://github.com/Fizzadar/pyinfra/commit/228460d004175ebd539bba641d27773eb955bc40 for release in1.3.7
shortly!