title: Cron script doesn't work unless called by sh command
body: <p>I have a script saved in file named file.sh
  It is executed by command</p>
  <pre><code>chmod +x file.sh
  </code></pre>
  <p>file.sh</p>
  <pre><code>#!/bin/sh
  find /var/log/*.gz  -printf &quot;%T@ %Tc %p\n&quot;|sort -n|tail -n +6|sudo xargs rm|echo&quot;test&quot;|wall
  </code></pre>
  <p>I am trying to execute it by cron job.</p>
  <p>Crontab</p>
  <pre><code>SHELL=/bin/bash
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  MAILTO=root
  
  # For details see man 4 crontabs
  
  # Example of job definition:
  # .---------------- minute (0 - 59)
  # |  .------------- hour (0 - 23)
  # |  |  .---------- day of month (1 - 31)
  # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
  # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
  # |  |  |  |  |
  # *  *  *  *  * user-name  command to be executed
  * * * * * root /etc/file.sh
  </code></pre>
  <p>Script is launched every minute by cron job, <strong>I am getting echo in terminal.</strong></p>
  <p>But <strong>xargs rm doest works</strong> . I do know why.</p>
  <p>When I execute command sudo sh file.sh, is OK, and file is deleted.</p>
  <p>Please help me find the reason why the script is not working in cron-job.
  It's strange.</p>
  <p>Thank You !</p>