0

I am having executing a cron call, and I am lost on what could it be causing the issue.

I initially had a crontab setup like this:

00 09 * * 1-5 root /usr/bin/curl -k "http://localhost/notifications/cronRuleAction?&auth_id=some-uuid&password=somehash&action=action&type=type&sequence=User Sequence, User Sequence, User Sequence"

Which did not work, as I learned curl does not accept whitespaces. Then, I added %20 to replace the whitespaces on the sequence parameter, so the crontab looks like this:

00 09 * * 1-5 root /usr/bin/curl -k "http://localhost/notifications/cronRuleAction?&auth_id=some-uuid&password=somehash&action=action&type=type&sequence=User%20Sequence,User%20Sequence,User%20Sequence"

If I execute this curl command manually, it gets executed, the url code runs and everything works as expected. However, if I let the crontab run, the cron command stops at the first %20 character, the curl does not run and the code in the url is not executed.

This is a copy of the cron service status after triggering:

May 11 09:00:01 pc CROND[33215]: (root) CMDEND (/usr/bin/curl -k "http://localhost/notifications/cronRuleAction?&auth_id=some-uuid&password=somehash&action=action&type=type&sequence=User)

I tried to append an xdebug remote flag to debug, and as expected, if I remove the whitespace from the url, it triggers and my IDE opens the request, however if I add either a whitespace or its %20 equivalent, the curl is never triggered and the IDE never receives the debug request.

What can I do to ensure the curl does not cut on a whitespace or its %20 equivalent?

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • You can also use `+` for spaces. – Barmar May 08 '23 at 19:51
  • Thank you @Barmar, the problem with the plus sign consists on the values of "User Sequence" themselves, because some of them may include this character and some other characters as well. – Juan Carlos Alpizar Chinchilla May 08 '23 at 20:29
  • If they contain `+` you need to use `%2B` for them. – Barmar May 08 '23 at 20:34
  • @Barmar I see, to be honest I don't want to start messing with encoding for any character we may find, if I change the request to be a post request, are the limitations put away since these are post parameters, and not part of the URL itself? – Juan Carlos Alpizar Chinchilla May 08 '23 at 20:45
  • 1
    Yes. If you use `-d` to post the parameters as POST data, it uses multipart/form-data rather than URL encoding. – Barmar May 08 '23 at 20:46
  • 1
    URL encoding should apply, so `%20` seems correct. But in a script context, the % sign can possibly introduce a placeholder or format, like for printf... did you try `%%20`? – Honk der Hase May 08 '23 at 22:30
  • @HonkderHase no, I did not try with `%%20` although escaping `%20` with a backslash did the trick, as % seems to be used by crontab itself as a newline character, which I did not know about until today :) thank you for your help – Juan Carlos Alpizar Chinchilla May 09 '23 at 02:45

0 Answers0