0

That I have:

I have some commands in crontab, for example:

55 11 * * * curl -d '{"explorerId":'$(cat /root/id)', "turnOff":true}' -H "Content-Type: application/json" -X POST http://localhost:8080/descriptions >> log/curl.log 2>&1

This command do something and saves result in file curl.log

That to need:

I want, that to each note adds a string with information, like:

Date: 15.09.2018. 
Execute command: description
Result:

#...result of log from curl command
  • 2
    Please don't do it like this. Put it in a script and execute the script. – Rinzwind Sep 13 '18 at 14:48
  • Fine). But in my case, I need to try this way. – Valentyn Hruzytskyi Sep 14 '18 at 20:22
2

You could try this:

55 11 * * * { echo -e "date: $(date -I)\nExecute command: description\nResult:\n"; curl -d '{"explorerId":'$(cat /root/id)', "turnOff":true}' -H "Content-Type: application/json" -X POST http://localhost:8080/descriptions ;} >> log/curl.log 2>&1

It will echo the date, discription and the result and append it in the log.

| improve this answer | |
  • 1
    +1 but I personally would put the code in a script and then simply call the script from cron instead of further increasing the length of the current line and fiddle around with weird quoting problems just to get all the code into one line. – PerlDuck Sep 13 '18 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.