ps aux output in cronjobs
Alexandru Bucur Sep 22
Going trough an ad-hoc cronjob for checking an existing process I've hit a weird case that the command itself was working well when ran from the terminal, but failed miserabely when the cronjob ran it.
The command was something along the lines of:
ps aux | grep 'php artisan a_specific_command --with-some-long-parameters-that were generated' | grep -v grep
The thing that I've completely forgotten is that by default
ps's output is limited by the number of
$COLUMNS. As a standard that's set to 80 chars (that of course you can easily change).
Because of that, the output line itself was truncated when ran trough the cron command (and worked well on my full hd screen that has aproximately 171 columns, you can test yourself by using
The easiest solution for fixing this is using the Wide output mode twice for unlimited width
ps auxww | grep 'php artisan a_specific_command --with-some-long-parameters-that were generated' | grep -v grep