Вы можете сделать это с помощью двухэтапного -процесса :скопировать метку времени, а затем изменить ее, чтобы она была старше:
#find the eldest file in dir
eldest=$(ls -t dir | tail -1)
#duplicate the time
touch -r "dir/$eldest" myfile
#make the file one second older
touch -A -000001 myfile
Я не смог воспроизвести ваш. Если команда для cron слишком громоздка, более элегантным способом будет поместить ее в отдельный скрипт cron и вызывать его из crontab:
$ cat ~/crontab.ip
#!/bin/bash
{ date +%FT%T | tr "\n" " "; curl https://ipinfo.io/ip -s ; echo "" ; } >> ~/log.ip
и мой crontab:
$ crontab -l
* * * * * ~/crontab.ip
Это должно сработать.
При размещении команд в системе cron необходимо использовать полный путь к команде.
То есть,
датадолжна быть/bin/date
trдолжно быть/usr/bin/tr
curlдолжно быть/usr/bin/curl.
эходолжно быть/usr/bin/echo
Так что это оказались символы '%'. Нужно было больше читать документы :crontab (5)
The "sixth" field (the rest of the line) specifies the command to
be run. The entire command portion of the line, up to a newline
or a "%" character, will be executed by /bin/sh or by the shell
specified in the SHELL variable of the cronfile. A "%" character
in the command, unless escaped with a backslash (\), will be
changed into newline characters, and all data after the first %
will be sent to the command as standard input.
Правильная строка cron, которая сработала в конце:
* * * * * { date +\%FT\%T | tr "\n" " "; curl https://ipinfo.io/ip -s ; echo "" ; } >> /home/mario/logs/pubip.log
Тем не менее, я перенесу это в сценарий только для удобочитаемости, как предложил @scimerman.