Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cron problems running very basic commands

Tags:

bash

path

cron

I have made a simple cron job by typing the following commands

crontab -e

then in the vi file opened I types

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

the file foo.txt indeed gets created, but its content is

/bin/sh: Applications: command not found

I'm guessing this has to do with the PATH value of cron. Is there any way to set the PATH in the cron file such that when I transfer it to another mac I won't have to set the PATH manually? is this even a PATH problem?

like image 937
WhiteTiger Avatar asked Aug 07 '15 05:08

WhiteTiger


People also ask

Why are my Cronjobs not running?

You might discover that your job works when run via the command line, but won't run via cron. This may be due to the location you're executing from or the PATH you're using. The use of relative paths is a common cause of cron issues. In cron, the PATH is set by default to /bin:/usr/bin .

How do you check if crontab is running correctly?

Method # 1: By Checking the Status of Cron Service Running the “systemctl” command along with the status flag will check the status of the Cron service as shown in the image below. If the status is “Active (Running)” then it will be confirmed that crontab is working perfectly well, otherwise not.

What is the use of * * * * * In cron?

It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .


1 Answers

I think you got one too many *'s there. And yes you can set the PATH variable in cron. A couple of ways. But your problem is the extra *.

like image 90
Red Cricket Avatar answered Sep 28 '22 01:09

Red Cricket