Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  25] [ 0]  / answers: 1 / hits: 98065  / 2 Years ago, wed, february 2, 2022, 10:41:05

I have a crontab file that looks like this:



* * * * * /home/abliskovs/update/update.sh



However when I check the syslog for evidence that the job has run, there is nothing that might indicate that it ever ran. How can I check if it's running?



crontab -l outputs the following:



* * * * * /home/abliskovs/update/update.sh


More From » cron

 Answers
4

Add a >>/tmp/testlog.log to the end of your crontab entry (to redirect
output to a file you can investigate or check if it's running,
additionally a 2>&1 would include output from the error console)




Example




0 * * * * /home/abliskovs/update/update.sh 2>&1 /tmp/testlog.log




Also Make Sure the followings :




  • Add cronjobs in a right manner. if you've used crontab -e within your own account, scripts are run with your user (and thus the
    crontab entry has one field less -- the user to run it, as that is
    known). If you simply copied your above snipped to /etc/cron.d, it
    would fail as you didn't specify a user (or rather as it finds no
    user named "bash").

  • Make sure that the script file is executable, otherwise it will not
    execute it.

  • Reload the cron jobs sudo service reload, or restart cron service sudo /etc/init.d/cron restart



How to make a file executable?



Several ways to make your file executable



chmod +x /home/abliskovs/update/update.sh 

chmod -R 0755 /home/abliskovs/update/update.sh

chmod a+x /home/abliskovs/update/update.sh

[#41094] Thursday, February 3, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nnaisdio

Total Points: 369
Total Questions: 112
Total Answers: 108

Location: Kenya
Member since Mon, Jun 14, 2021
3 Years ago
;