0
*/5 * * * * root /mnt/efs/fs1/ec2Apache/validacao.sh

the script executes the echo command and sends the text to an online.txt file, however when executed by crontab the online.txt file is not found

when run normally without crontab the script works

erro:

Mar 30 16:46:01 ip-xxx-xx-xx-xxx.ec2.internal CROND[99999]: (root) CMDOUT (/mnt/efs/fs1/ec2Apache/validacao.sh: line 14: dir/online.txt: No such file or directory)

  • Use the absolute pathname of the `online.txt` file. The script's working directory isn't what you expect. – Barmar Mar 30 '23 at 20:12
  • 1
    It's looking for `~root/dir/online.txt`. – Barmar Mar 30 '23 at 20:13
  • See https://stackoverflow.com/tags/cron/info . Good luck. – shellter Mar 30 '23 at 21:37
  • The duplicate has a number of troubleshooting steps. If you still need more help, please [edit] to indicate what you have done to debug the problem; but this is almost certainly a simple case of [What exactly is current working directory?](https://stackoverflow.com/questions/45591428/what-exactly-is-current-working-directory) – tripleee Mar 31 '23 at 06:15

1 Answers1

-1

Try in below way

*/5 * * * * /usr/bin/bash /mnt/efs/fs1/ec2Apache/validacao.sh

or

*/5 * * * * /usr/bin/sh /mnt/efs/fs1/ec2Apache/validacao.sh