Where do I put cron commands? [closed] - cron

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I see a bunch of tutorials for cron commands like
0 */5 * * * /some_sript.sh
But what file do I put this line of text in?

From tag:crontab info
Basic commands
crontab -e Edit crontab.
crontab -l Show crontab current information.
Also, you'd better write
0 */5 * * * /bin/sh /some_sript.sh
instead of
0 */5 * * * /some_sript.sh
That is, indicate the binary executing the script.

You just need to run "crontab" command to edit the cron table. Try to "man crontab".

Related

Searched everywhere but cannot run my own sample bash script with crontab [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
#!/usr/bin/env bash
#!/bin/bash
#!/bin/sh
filename='/home/supersaiyan/sample1.sh'
for i in 1 2 3 4 5
do
echo "String $i"
x1+="String"$i
done
echo "#Added string is: $x1" >> $filename
echo "The following string has been added to the file: $x1"
Here's the bash script I created which runs fine when using the bash command. It doesn't work in crontab though.
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
5 * * * * echo '#tanginamo cron tester' >> /home/supersaiyan/samplerz.sh
* * * * * /bin/bash /home/supersaiyan/sample1.sh
Here's what I put in crontab. The first line is just for testing and is working fine so I'm really lost on why the second one isn't working.
EDIT: Tried removing the SHELL and PATH lines to no avail
The .sh file is already modified as executable
Your output should be going to a different file than your actual script file.
You need to change :
filename='/home/supersaiyan/sample1.sh'
to:
filename='/home/supersaiyan/sample1.out'
...and run the script again.
You may want to review it's contents past line 10 or so.
Enjoy! :)

Crontab -e Doesn't run the script at a given hour [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have this python3 script found at /root/Desktop.security/test.py.
Would like it to run everyday at 10:03, 15:03 and 22:03. Tried all these settings in crontab, but still doesn't run my file. I tried even at reboot
# * * * * * /usr/bin/python3 /root/Desktop.security/test.py
#reboot /usr/bin/python3 /root/Desktop.security/test.py &
03 10,15,22 * * * /usr/bin/python3 /root/Desktop.security/test.py
03 10,15,22 * * * python3 /root/Desktop.security/test.py
What I am doing wrong?
Thank you!
had a typo in the command, the path had a dot in it and also the script has to be run with python3 location of script.py.
The information that you have to give the full path of python executable is obsolete. ==> therefore the correct answer is 03 10,15,22 * * * python3 /root/Desktop/security/test.py

How to debug why my Cron job is running twice? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
When I execute my cron manually everything seems to work. However when it runs by cron it seems to run twice. In my deployment script I have the following two lines to add my crons:
/usr/bin/crontab -l | { /bin/cat; /bin/echo "* 3 * * * /etc/app/execute.py"; } | /usr/bin/crontab -
/usr/bin/crontab -l | { /bin/cat; /bin/echo "* 0,2,4,6,8,10,12,14,16,18,20,22 * * * /etc/app/solr.py"; } | /usr/bin/crontab -
Is there any reasonable reason why my CRON might be running twice on my debian server? I have no idea what might be causing this or how to debug it.
In my Crontab I have this:
* 3 * * * /etc/app/execute.py
* 0,2,4,6,8,10,12,14,16,18,20,22 * * * /etc/app/solr.py
You can debug this by adding something like
; echo $(date) ; echo "Cron line one" >> /root/cronlog
That way you can see which line was executed when.
Also, how do you edit your cronjobs? With "crontab -e" or by directly editing the files? If you edit the files directly (which I don't recommend), then please compare the content of the files with the output of "crontab -l".

Ubuntu - cron not running script [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Ok, so I'm trying to set cron to run a bash script at a certain time. My bash script is essentially this
#!/bin/bash
espeak -g 3 "this is my text"
So from there, I went to the crontabs, and added in
*/1 * * * * /path/to/my/script.sh
to see if it would run, but it didn't do anything. I changed the script to
#!/bin/bash
echo "this is my script"
to see if that would do anything, but no avail. Any help? Thanks.
Try to run the script manually and see if it echos out: bash /path/to/my/script.sh
Does the file have the correct permissions?
Try Outputting errors to a log file: */1 * * * * /path/to/my/script.sh > /path/to/my/error.log 2>&1

Crontab in Linux shell using putty [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
This may be very elementary but i am a a beginner when it comes to Linux shell.
I use putty to connect to the server.
I manage to login to the shell just fine. But there doesn't seem to be any option for running crontab commands.
Do i need to access any other file on the server first?
Like cd /var/spool/cron ?
I want to create a simple cronjob that starts a php file every 10 minutes today:
*/10 * 13 11 2 /PATH/mail.php
I'm blank, but it seems like i could do something like this to create a crontab file.
vi allcron
crontab allcron
When i do this i get to a new window. What to do here?
Thanks for any help!
You should use the crontab edit/list functions to add/remove your cron jobs.
crontab -e (to edit) opens an editor with the cron jobs. Simply add your statement or append if there are already cronjobs listed: */10 * 13 11 2 /PATH/mail.php
crontab -l to view your cronjobs.
See http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5 for more info or type "man crontab" in your shell for the manual page.
Also note that your user must have privileges to manipulate cronjobs. Typically each user should have access to their own crontab for most cron daemons.

Resources