0

I'm trying to create a log file for cron job on my jelastic/virtuozzo platform. I have a syntax to create a cron job every 2 minutes:

*/2 * * * * wget -q -O /var/www/webroot/ROOT/cron_log https://someweb.com/dev/api/order/cron-get-order

But no log file is created/updated. For information: the log is created before at var/www but it came messy because it created so many file log in that folder, so I want to make it neat.

Cross Vander
  • 2,077
  • 2
  • 19
  • 33
  • I’m voting to close this question because, from the cron tag: Questions about configuring cron for systems or administration are OFF TOPIC. – Rob Mar 09 '23 at 16:09
  • As a general tip, check if your command does what you want/expect via an interactive SSH session first. If everything is good, your only remaining problems to convert it to a cron expression are the timing and environment aspects (environment is why I recommended to use the full path to wget, in case it's not available in $PATH) – Damien - Layershift Mar 09 '23 at 16:16
  • yes, my cron work normally, but i want to move log to another folder – Cross Vander Mar 09 '23 at 16:43

1 Answers1

1

Why ./var ?

I suspect that your problem is because you're not using the full path to wget (try /usr/bin/wget instead)

Also, since you're using wget -q, perhaps you don't have any output to append?

wget --help excerpt:

Logging and input file:
  -o,  --output-file=FILE    log messages to FILE.
  -a,  --append-output=FILE  append messages to FILE.
  -d,  --debug               print lots of debugging information.
  -q,  --quiet               quiet (no output).
  -v,  --verbose             be verbose (this is the default).
  -nv, --no-verbose          turn off verboseness, without being quiet.
       --report-speed=TYPE   Output bandwidth as TYPE.  TYPE can be bits.
  -i,  --input-file=FILE     download URLs found in local or external FILE.
  -F,  --force-html          treat input file as HTML.
  -B,  --base=URL            resolves HTML input-file links (-i -F)
                             relative to URL.
       --config=FILE         Specify config file to use.
Damien - Layershift
  • 1,508
  • 8
  • 15
  • basically my cron for this syntax is working good `*/2 * * * * wget -q https://someweb.com/dev/api/order/mycron` but it create a numerous log that made my folder messy, so what should I do to fix that? – Cross Vander Mar 09 '23 at 16:09
  • @CrossVander what is the result that you want? Maybe edit your question to explain that a bit more clearly. Perhaps include both the "working but wrong result" and "not working" cases and explain what's wrong about the working one / what you were hoping to achieve with the changed version. – Damien - Layershift Mar 09 '23 at 16:13
  • Oh, you gave me a good hint.. I've changed my cron to `*/2 * * * * wget -q -O /var/www/webroot/ROOT/cron_log https://someweb.com/dev/api/order/cron-get-order` but still no file append to the folder. should i remove `var`? and for additional info, my corn is working well, just need to change the log file location – Cross Vander Mar 09 '23 at 16:17
  • finally i change it to: `*/2 * * * * wget -a /var/www/webroot/ROOT/cron_log/update_order.log https://someweb.com/dev/api/order/cron-update-order` and it works perfectly... – Cross Vander Mar 09 '23 at 19:47