According to documentation , to attach to the log file without replacing the previous one should use the parameter -a
, it does the same as the parameter -o
only instead of replacing the log of the file with generated, it appends to the old one.
wget http://www.example.com -a Logs.log
If the logs are already in the logslog file , the log file will be created.
EDIT
You can use cURL , in the simple example below, I've created a .sh file. >:
#!/bin/sh
STATUS=$(curl -s -o /dev/null -w '%{http_code}' https://pt.stackoverflow.com/naoexiste)
DATA=$(date '+%d/%m/%Y %H:%M:%S')
if [ ! $STATUS -eq 200 ]; then
echo -e "$DATA - $STATUS" >> /var/www/logs/Logs.log
fi
Explanation
Parameters:
We run a condition that checks whether the value contained in the STATUS
variable is different from 200
, otherwise it saves the status in the log.
To schedule the task, simply:
* * * * * /home/USUARIO/executa_tarefa.sh
Reference