-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cron job command within the mirrors wiki doesn't seem to work #275
Comments
I believe the listed command is correct due to how
When running this command manually in the shell, it will error out as you noted. When ran in a crontab, it should run successfully. [root@cron-test ~]# crontab -l
* * * * * echo $(((RANDOM\%3500)+1)) >> /tmp/cron-orig.log
* * * * * echo $(((RANDOM%3500)+1)) >> /tmp/cron-new.log
[root@cron-test ~]# rm -f /tmp/cron-*.log
[root@cron-test ~]# ls /tmp/cron*.log
/tmp/cron-orig.log
[root@cron-test ~]# cat /tmp/cron-orig.log
946
734 The second command fails out when ran in the crontab in this instance, while the original command produces the expected output. Can you verify that the cron is actually failing due to a syntax error, or is something else happening when the command is being ran? |
What exactly do you need from me? If you run the command from bash it will fail: Should you want to stick to the crontab manual, fine; don't change it; people will adapt regardless I cannot be academic about it; I don't master bash; I am merely telling you that two people already went beyond the man pages of crontab and found that the escaping backslash doesn't work; perhaps a significant one from AlmaLinux should ask the crontab developers why; I am a mirror provider with an error hoping for a resolution from the community |
It is expected that the command from the crontab line will fail when running it in the shell manually due to it having the extra If you're running the command outside of the crontab, you would want to remove the (
I'm unable to replicate this using a stock AlmaLinux 8 install. Can you try the following for me and let me know what you see:
* * * * * sleep $(((RANDOM\%3500)+1)) && echo "Yay, I worked!"
* * * * * sleep $(((RANDOM%3500)+1)) && echo "I did not work"
If you see something like this, that means the command in the wiki should be working as intended: Jun 15 19:26:01 cron-test CROND[1319991]: (root) CMD (sleep $(((RANDOM%3500)+1)) && echo "Yay, I worked!")
Jun 15 19:26:01 cron-test CROND[1319992]: (root) CMD (sleep $(((RANDOM) |
I am telling you that I have ran this command within webmin crontab and it failed; I have left this command to simply be executed by crontab and it has never updated the timespamp.txt file while having the \ in the command. After removing it, the timpestamp.txt started to reflect the date I was in. Should you want to acknowledge this or not it is up to you. |
Can you try from within shell using |
I think the Webmin portion is the missing piece we needed. Do you know if it's adding the command to the I believe if it's using the @jonathanspw I need to verify that is the behavior we're seeing here, but if so I think we should consider either a different command that's more POSIX compliant / less finicky if being ran outside of the crontab. |
I am getting Jun 16 12:12:01 hosting CROND[1141219]: (root) CMD (sleep $(((RANDOM) |
It looks like the crontab line is proper and working as intended, however due to this causing confusion and being a bit ambiguous, we're going to provide alternative instructions for a systemd timer. I'm going to be closing this issue. You can follow the changes in #277 |
My cron job crashes with
/bin/sh: (RANDOM\%3500)+1: syntax error: invalid arithmetic operator (error token is "\%3500)+1")
however if I take out the backslash and only leave
sleep $(((RANDOM%3500)+1))
it does seem to work.Maybe point 3 in the https://wiki.almalinux.org/Mirrors.html page should be changed?
The text was updated successfully, but these errors were encountered: