- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Cron is not working...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2006 07:34 PM
12-12-2006 07:34 PM
I am able to execute 1 script using #./tmp/script.sh
and can get the desired output on my email.
I want to run this script in every 15 minutes so i made some entries in crontab file
# crontab -e
00,15,30,45 * * * * /tmp/script.sh
But now i am not getting any mail
# ps -ef | grep -i cron
root 3348 1 0 Nov30 ? 00:00:00 crond
root 31075 23905 0 02:34 pts/7 00:00:00 grep -i cron
#
Please suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2006 07:50 PM
12-12-2006 07:50 PM
Re: Cron is not working...
* * * * * date > /tmp/cron.test
in crontab file
and it is working fine...
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2006 01:14 AM
12-13-2006 01:14 AM
Re: Cron is not working...
MAILTO=
to explicitly assign the mail user;
2.
check /var/log/crontab to see your cronjobs had been invoked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2006 01:15 AM
12-13-2006 01:15 AM
Re: Cron is not working...
it should be
/var/log/cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2006 10:17 AM
12-13-2006 10:17 AM
Re: Cron is not working...
Generally, only a bare-minimum of PATH is set in the cron environment.
Basically, you've got two choices:
1) Make sure the path you require is set within the script.
2) Absolutely-path every command you call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2006 08:05 PM
12-14-2006 08:05 PM
Re: Cron is not working...
Dec 15 02:50:01 hostname crond[11336]: (root) CMD (/opt/wlserver/ldm1v4.sh)
I am getting this message on every minutes.
/opt/wlserver/ldm1v4.sh is the script which i am trying to execute using cron.
where i need to add "MAILTO"?
I think path is set because if i give this command..
#/opt/wlserver/ldm1v4.sh
then script is successfully executing.
please suggest
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2006 06:53 PM
12-15-2006 06:53 PM
Re: Cron is not working...
As this isn't "/tmp/script.sh", I don't see how that's relevant.
Now, back to the PATH issue. Executing a command from the command line *IS NOT THE SAME* as having it execute from cron.
The PATH environment variable is different. STDIN, STDOUT and STDERR are different when executed from cron. Lots of things are different when executed from cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2006 04:19 AM
12-16-2006 04:19 AM
Re: Cron is not working...
i think the syntax is incorrect.
Try first with a classical command, without comma, example:
10 4 1 * * /tmp/script.sh
Then, check if you have cron.allow file.
Bye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 01:19 AM
12-18-2006 01:19 AM
Re: Cron is not working...
Alpha is correct.
The syntax that you have used in the crontab file is incorrect.
The format which Alpha has also mentioned will be ---
15 * * * *
Then restart your crond service and then see if it gets executed or not.....
Also you can check your cron jobs using crontab -l command
Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 09:02 AM
12-18-2006 09:02 AM
Re: Cron is not working...
There's nothing wrong with a comma-delimited set of minute values. Go back and re-read your man pages.
Also, if using 'crontab -e', the '/etc/crontab' file or '/etc/cron.d/' structure, there's no need to restart 'crond'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 05:51 PM
12-18-2006 05:51 PM
Re: Cron is not working...
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 08:20 PM
12-18-2006 08:20 PM
Re: Cron is not working...
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
that sort of thing.
Do 'echo $PATH' in the shell to get what it's currently set to.. copy/paste that in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 09:34 PM
12-18-2006 09:34 PM
Re: Cron is not working...
but still that script is not running using cron.
if i execute this script using #./script.sh
, I am getting the correct output.
when i am using cron....even I am not getting any thing in /var/log/maillog
(This script send me the output to my email id)
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 10:42 PM
12-18-2006 10:42 PM
Re: Cron is not working...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 10:57 PM
12-18-2006 10:57 PM
Re: Cron is not working...
if the process is not running, script will send the email. (mailfile is a script to send the emails)
# cat ldm1v4.sh
PATH="/home/db2home/SymphonyRPM/Server/Python23:/home/db2home/SymphonyRPM/Share:/home/db2home/SymphonyRPM/Server/ldap:/home/db2home/SymphonyRPM/Server/stubs::/home/db2home/SymphonyRPM/server:/home/db2home/SymphonyRPM/server/Python23:/home/db2home/SymphonyRPM/share:/home/db2home/SymphonyRPM/server/ldap:/home/db2home/SymphonyRPM/Server/stubs::/usr/local/nz/bin:/opt/CA/SharedComponents/dmscript/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin"
NUM_PROC=$(ps -ef |grep -c ldm1v4)
if [[ $NUM_PROC = 1 ]]
then
/opt/wlserver/mailfile_ldm1v4.sh praveen@hp.com root@hostname.company.com 1 2 `hostname`::wlserver process is running
fi
and I also tried with #!/bin/sh
# cat ldm1v4.sh
#!/bin/sh
PATH="/home/db2home/SymphonyRPM/Server/Python23:/home/db2home/SymphonyRPM/Share:/home/db2home/SymphonyRPM/Server/ldap:/home/db2home/SymphonyRPM/Server/stubs::/home/db2home/SymphonyRPM/server:/home/db2home/SymphonyRPM/server/Python23:/home/db2home/SymphonyRPM/share:/home/db2home/SymphonyRPM/server/ldap:/home/db2home/SymphonyRPM/Server/stubs::/usr/local/nz/bin:/opt/CA/SharedComponents/dmscript/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin"
NUM_PROC=$(ps -ef |grep -c ldm1v4)
if [[ $NUM_PROC = 1 ]]
then
/opt/wlserver/mailfile_ldm1v4.sh praveen@hp.com root@hostname.company.com 1 2 `hostname`::wlserver process is running
fi
If i give the command...
#./ldm1v4.sh
I got the desired result
this script is not working with cron
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 11:26 PM
12-18-2006 11:26 PM
SolutionCheck the messages file for any cron errors, restart crond, ensure that 'crontab -l' shows the right stuff, that the file is actually there and is executeable (+x), that the security policy allows for it to execute outside of a shell (audit.log possibly)...
Time to grasp at straws.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2006 01:23 AM
12-19-2006 01:23 AM
Re: Cron is not working...
BUt If it is not, follow the steps below:
1. in file /var/log/cron, check your script/cronjob has been started
2. If not, check your crontab syntax
3. If yes, append ">>& /tmp/cron.log" on the problematic entry of your crontab, and add some debug info in your script
What's your shell? is it bash or csh? The path setting is different.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2006 05:28 PM
12-20-2006 05:28 PM
Re: Cron is not working...
while I was using ...if [[ $NUM_PROC = 1 ]]
in my script..
Thanks everybody :-)