I'm stuck on logrotate mystery I'm stuck on logrotate mystery nginx nginx

I'm stuck on logrotate mystery


Your redirections are incorrect in those cron lines. They will not output error information to those files.

Redirection order matters. You want >/tmp/logrotate_size 2>&1 to get what you want.

The underlying issue here is one of the things covered by the "Debugging crontab" section of the info page.

Namely "Making assumptions about the environment".

Making assumptions about the environment

Graphical programs (X11 apps), java programs, ssh and sudo are notoriously problematic to run as cron jobs. This is because they rely on things from interactive environments that may not be present in cron's environment.

To more closely model cron's environment interactively, run

env -i sh -c 'yourcommand'

This will clear all environment variables and run sh which may be more meager in features that your current shell.

Common problems uncovered this way:

foo: Command not found or just foo: not found.

Most likely $PATH is set in your .bashrc or similar interactive init file. Try specifying all commands by full path (or put source ~/.bashrc at the start of the script you're trying to run).