Cron Unix dude with shell - shell

I need make a task with cron but it doesn't work.
My code cron
*/1 * * * * /home/script.sh
does not call the script.

Try to check your path to the script. Maybe it is located in user directory.
*/1 * * * * /home/user/script.sh

Related

How do I activate cron job?

I edited the cron file on my Mac running catalina.
I used this code:
crontab -e
And then I added this line
* * * * * python3 ~/Documents/Scripts/script.py
My expectation is that it should run every minute but it hasn't run once.
Do i need to do something special to activate cron on this machine?
Updated my code based on the conversation in the comments to this
* * * * * /usr/local/bin/python3 ~/Documents/Scripts/script.py >>~/Documents/Scripts/script.log 2>&1

Cron job with shell script

i am trying to run a shell script using cronjob after every 2 minutes. I opened my terminal then typed
crontab-e
once i execute this command i am writing my command
*/2 * * * * /home/test/test/test.sh
but i am getting an error as
E486: Pattern not found: 2 * * * *
please help as i am new to this and i don't know why it is happening.
If you give me any links and code on hwo to execute cronjob it would help.
As mentioned in comments, the following error:
E486: Pattern not found: 2 * * * *
Was caused because you were not editing properly. That is, you were saying crontab -e correctly and then you were entering in vi. Instead of going into the insert mode, you would directly type */2 * * * * /home/test/test/test.sh, which vi would try to perform as a command, which is not.
So what you have to do is to press i to enter in the write mode. And then, just then, write */2 * * * * /home/test/test/test.sh. Finally, save the file by saying :wq.
In case other problems occur in your cronjob, you may want to check the "Debugging crontab" section in https://stackoverflow.com/tags/crontab/info.
I would like to show it in more detail:
crontab -e
i
* * * * * cd path/to/your/project && command
ESC
:wq
ENTER
Please check the link in the correctly marked answer above for learning more about crontab.

Running script crontab Mac OS X

I have created a script that empties the Trash every 5 minutes. However, I am not able to run the script.
Here is the location of the script.
/Users/Ryan/Documents/trash.sh
Here is what my crontab looks like.
*/5 * * * * /Users/Ryan/Documents/trash.sh
Any ideas why it's not working? Thanks in advance.
I found the answer.
*/5 * * * * sh /Users/Ryan/Documents/trash.sh

CRON JOB is not running script

I'm trying to schedule a cron job here is my command:
*/5 * * * * USER -q /path/cron.php -mdefault 1
I'm trying to run this magento script every 5 minutes. I see the command being run when I open the cron log via grep CRON /var/log/syslog.
unfortunately the script never executes. I would appreciate any help.
Edit the crontab of the user you want to assign the job to:
sudo -u USER crontab -e
then in the crontab you can schedule the cron.php job in the following way:
*/5 * * * * php /path/to/cron.php

cron job not working for xwindow

I have following line in crontab
*/1 * * * * xeyes
it does not show any xwindow but on the contrary
*/1 * * * * touch somefile.txt works fine
Tried to search on google but didnt get any specific answers!!
You have to tell cron where to find the X server if the command you run uses it.
So use: env DISPLAY=:0.0 xeyes or export DISPLAY=:0.0; xeyes.
Some cron implementations (Debian, Ubuntu, ...) allows to set enviroment simply in cron file.
DISPLAY=:0.0
# m h dom mon dow command
*/1 * * * * xeyes

Resources