I am running crontab -l to view the crons on a RHEL server(v5.10) and getting the below error:
crontab: error while loading shared libraries: libaudit.so.1: cannot open shared object file: No such file or directory
I am running the command via root user. If I go to /etc and open the crontab file using the cat command I am getting the following output:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
Related
I have a daily batch run in django with cron.
# crontab -e
All but the bottom of these batches seem to work correctly.
0 0 * * * root /root/certbot.sh
0 18 * * * root /var/www/html/venv/bin/python /var/www/html/portfolio/mysite/manage.py daily_import_from_vietkabu
5 18 * * * root /var/www/html/venv/bin/python /var/www/html/portfolio/mysite/manage.py daily_import_from_sbi
6 18 * * * root /var/www/html/venv/bin/python /var/www/html/portfolio/mysite/manage.py daily_import_from_bloomberg
15 18 * * * root /var/www/html/venv/bin/python /var/www/html/portfolio/mysite/manage.py daily_industry_chart_and_uptrends
20 18 * * * root /var/www/html/venv/bin/python /var/www/html/portfolio/mysite/manage.py daily_industry_stacked_bar_chart
30 18 * * * /root/collectstatic.sh << this!!
The shell script that is triggered has the following written
(/root/collectstatic.sh)
# /bin/sh
cd /root
source /var/www/html/venv/bin/activate
python3 /var/www/html/portfolio/mysite/manage.py collectstatic --noinput
The command at the bottom is the standard django command to copy static files to a fixed location. These batches with cron, as far as I remember, came straight from the migration from "CentOS" and may not work well with current ubuntu with cron.
Has anyone ever run django's collectstatic with ubuntu's cron?
thanks.
I am trying with these 2 scripts:
test1,sh:
#!/bin/sh
NOW=$(date +"NOW;%Y;%m;%d;%H;%M;%S")
echo -n $NOW | nc -u -q 2 -w 2 192.168.0.252 4210
test2.sh:
#!/bin/sh
NOW=$(date +'NOW;%Y;%m;%d;%H;%M;%S')
echo -n $NOW > /dev/udp/192.168.0.252/4210
Both scripts works fine when directly execute on terminal, client successfully receiving the UDP packets.
*/5 * * * * root /etc/test/test1.sh
*/5 * * * * root /etc/test/test2.sh
But doesn't work when executing in CRON, client did not receive the UDP packets.
**sudo grep CRON /var/log/syslog**
Mar 10 16:40:01 localhost CRON[12281]: (CRON) info (No MTA installed, discarding output)
Mar 10 16:40:01 localhost CRON[12286]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Mar 10 16:40:01 localhost CRON[12287]: (root) CMD (root /etc/test/test1.sh)
Mar 10 16:40:01 localhost CRON[12289]: (root) CMD (root /etc/test/test2.sh)
Please help
Is the next to last block the output of crontab -l? Looks to me like there's an extra "root" in there.
The hint is in your syslog output:
Mar 10 16:40:01 localhost CRON[12289]: (root) CMD (root /etc/test/test2.sh)
Remove the root from your crontab and you'll have better luck.
i have a problem with crontab not running a script of mine at all. i have simplified the script down to a single line but it still won't run:
$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 * * * * root /usr/share/test/script.sh
# don't forget the newline at the end (https://askubuntu.com/a/23337/12057):
$ cat /usr/share/test/script.sh
#!/bin/bash
echo "got here" > /tmp/test.txt
$ ls -l /usr/share/test/script.sh
-rwxr-xr-x 1 root root 951 May 8 08:59 /usr/share/test/script.sh
$ uname -a
Linux mypcname 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
$ ps aux | grep cron
root 1111 0.0 0.0 22222 3333 ? Ss 08:27 0:00 /usr/sbin/cron
me 4444 0.0 0.0 5555 666 pts/0 S+ 09:06 0:00 grep --color=auto cron
as you can see the crontab should run script.sh once a minute and write to file /tmp/test.txt, however this file never appears. i have been reading through these possible reasons for cron not running, but so far none of them are applicable. i thought a fresh set of eyes might shed some light.
Every minute is
* * * * *
not
*/1 * * * *
Related question: Using crontab to execute script every minute and another every 24 hours
/var/log/syslog gave the clue to the answer:
May 8 08:50:01 mypcname /usr/sbin/cron[2222]: (*system*) WRONG FILE OWNER (/etc/crontab)
May 8 08:51:01 mypcname /usr/sbin/cron[2222]: (*system*) WRONG FILE OWNER (/etc/crontab)
$ ls -l /etc/crontab
lrwxrwxrwx 1 root root 24 Oct 12 2013 /etc/crontab -> /home/me/.crontab
$ ls -l ~/.crontab
-rw-r--r-- 1 root root 24 Oct 12 2013 /home/me/.crontab
i remember i did this when i installed the debian os since everything in my home dir is checked out from a subversion repository. i fixed up the issue like so:
$ sudo cp ~/.crontab /etc/crontab
and now it all works fine :)
I have a crontab in fedora 17 with command
13 10 * * * /home/pk1/Templates/dump.sh
In dump.sh
#!/bin/sh
mysqldump --host=localhost --user=root --password=toor mba_new | gzip > /home/pk1/Templates/`date +"webt-backup_%m-%d-%y"`.gz
In log file have an error
Mar 25 10:13:01 area7 crond[31770]: (*system*) RELOAD (/etc/crontab)
Mar 25 10:13:01 area7 crond[31770]: (CRON) bad command (/etc/crontab)
if I run through terminal
sh dump.sh
everything is ok
Why my dump.sh not work through crontab? Thanks
Your crontab needs a username Please specify it as
13 10 * * * pk1 /home/pk1/Templates/dump.sh
I have a script in /etc/cron.daily/backup.sh file is allowed to execute and run but do not start happening, I read the manual and used the search but not mastered decision.
ls -l /etc/cron.daily/
total 52
-rwxr-xr-x 1 root root 8686 2009-04-17 10:27 apt
-rwxr-xr-x 1 root root 314 2009-02-10 19:45 aptitude
-rwxr-xr-x 1 root root 103 2011-05-22 19:08 backup.sh
-rwxr-xr-x 1 root root 502 2008-11-05 03:43 bsdmainutils
-rwxr-xr-x 1 root root 89 2009-01-27 00:55 logrotate
-rwxr-xr-x 1 root root 954 2009-03-19 16:17 man-db
-rwxr-xr-x 1 root root 646 2008-11-05 03:37 mlocate
The cron job filename can't have a period in it on certain ubuntus. See this. Particularly, this quote within:
Although the directories contain periods in their names, run-parts
will not accept a file name containing a period and will fail silently
when encountering them
Properly, this is a problem with run-parts, which the ubuntu cron runs, and not with cron itself. Still, it's what bit me.
pls check:
1a) is the script executable and has correct owner/group settings?
1b) does it start with the correct #! line? and do you specify the full path to the shell you're using,
e.g. #!/bin/bash ?
2) does the script generate an error while being executed?
e.g. can you write to a log file from it, and do you see the log messages?
also: check in the email inbox of the user who owns the crontab -- errors are emailed to the user / e.g. root
what does the output of ls -l /etc/cron.daily/ look like? can you post that?
NOTE:
you can always create a crontab entry for this yourself, outside of those cron.xxx directory structure ;-)
See: man 5 crontab
10 1 * * * /somewhere/backup.sh >> /somewhere/backup.log 2>&1
this has the advantage that you get to pick the exact time when it runs (e.g. 1:10am here), and you can redirect STRERR and STDOUT to append to a log file for that particular script
For testing purposes you could run it ever 10 minutes, like this:
0,10,20,30,40,50 * * * * /somewhere/backup.sh >> /somewhere/backup.log 2>&1
do touch /somewhere/backup.log to make sure it exists