Closed ashishprasher closed 2 years ago
@ashishprasher I can't reproduce this one. I tested in macOS (node v12) and linux (node v15). Can you show your code, and post your OS, node, and crontab versions.
Hi @dachev, Thanks for looking into this. Sharing the required information below:
OS: Debian GNU/Linux 9.1 Node version: v10.17.0 crontab version: 1.4.2
cron = { frequency: '*/15 * * * *', cronId: 'uniqueId', command:
curl --location --request POST 'http://localhost/execute-cron' --header 'Content-Type: application/json' --header 'su-secret: secret' --data-raw '{ "tenantId" : "ten", "cronEvent": "testing"}' }; crontab.create(cron.command, cron.frequency, cron.cronId);
@ashishprasher the cron
assignment throws an error. This is not valid JS code.
@dachev
I changed the '`' due to formatting issues to ". and that created the above issue. Kindly ignore the above mistake and reopen this issue.
@dachev I have updated the previous comment, Do I need to open another issue for this now?
@ashishprasher this is still not valid JS.
cron = {
frequency: '/15 *',
cronId: 'uniqueId',
command: curl --location --request POST 'http://localhost/execute-cron' --header 'Content-Type: application/json' --header 'su-secret: secret' --data-raw '{ "tenantId" : "ten", "cronEvent": "testing"}'
};
attaching screenshot for reference github's formatting is creating issue for you I think. Let me try again
cron = { frequency: '*/15 * * * *', cronId: 'uniqueId', command:
curl --location --request POST 'http://localhost/execute-cron' --header 'Content-Type: application/json' --header 'su-secret: secret' --data-raw '{ "tenantId" : "ten", "cronEvent": "testing"}' };
@ashishprasher once again, you've pasted invalid JS. Pay attention that it's different from what you have in the screenshot. I don't have time to help you with JS syntax but I'll help you with this: your original problem is almost certainly caused by a JS syntax problem when creating the cronjob. Focus your attention on that. I won't be able to respond to any further messages.
Hi @dachev Thanks for trying to help. I am pasting the exact JSON object here which was there in the screenshot. But due to GitHub code editor, it's getting changed.
Because of this bug, we are having to use GET request instead of POST. and I have shared the command earlier in the issue as well.
And if the problem was there with JS syntax, then code should break and it should not create any crontab entry
I am trying to save the below command
curl --location --request POST 'http://localhost/execute-cron' --header 'Content-Type: application/json' --header 'su-secret: secret' --data-raw '{ "tenantId" : "ten", "cronEvent": "testing"}'
But it gets saved only till first comma, comment is also not getting saved
@daily curl --location --request POST 'http://localhost/execute-cron' --header 'Content-Type: application/json' --header 'su-secret: secret' --data-raw '{ "tenantId" : "ten"