Cron issues running very simple commands

I made a simple cron job by typing the following commands

crontab -e

      

then in the vi file that opens, I type

* * * * * * echo 'leon trozky' >> /Users/whitetiger/Desktop/foo.txt 2>&1

      

the file is foo.txt

indeed created, but its contents are

/bin/sh: Applications: command not found

      

I assume it has something to do with the PATH value cron

. Is there a way to set the PATH on a file cron

in such a way that when I transfer it to another Mac, I don't have to set the PATH manually? is it even a PATH problem?

+3


source to share


2 answers


I think you have too much in there *

. And yes, you can set the PATH variable in cron. Several ways. But your problem is additional *

.



+4


source


Yes, your syntax is 1 * more than it should be, just adding more information, adding Red Cricket's answer, the crontab syntax should be



* * * * *  command to execute
โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€ day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ month (1 - 12)
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of month (1 - 31)
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ hour (0 - 23)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ min (0 - 59)

      

0


source







All Articles