-3

i have problem with crontable in shell I always write cronjob like this

0 * * * * /tmp/myscript

but now im on different shell and to use my script i need write like this

bash-4.2$ bash /tmp/myscript

And thats problem because when I write cronjob like this

* * * * * /tmp/myscript or bash /tmp/myscript ---> thats not work

How to solve this problem?

Renaud Pacalet
  • 25,260
  • 3
  • 34
  • 51

1 Answers1

0

You must use this structure for Crontab:

* * * * * user-name command to be executed

By the way, first, you should rename myscript to myscript.sh and run it.

For example:

17 * * * * root bash /tmp/myscript.sh
Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • I didn't downvote, but note that there's no need to rename `myscript` since extensions are irrelevant. You can even do `bash myscript.exe` as long as `myscript.exe` contains valid bash. – tdy Oct 10 '21 at 07:57
  • Yeah, i do like this and cron work in log Oct 10 10:00:01 SERV_NAME CROND[14025]: (user) CMD (user echo " " >> /tmp/myscript_result.txt) But the file has not been edited – fresco357 Oct 10 '21 at 08:16