Jobs run by cron run in background with no terminal context. Any output from your cron will not go to a terminal. It will go to unix mail for the user who owns the cron (unless you redirect the output to a log file).
Please post what Operating System and version you have and what Shell the script was written to use. The default Shell for cron is usually /bin/sh which on some O/S like Solaris is a very old Bourne Shell.
Please mention which user owns this crontab and post the output from:
Its showing
You have new mail in /var/spool/mail/root
But how to check that mail..??
And also the script hasn't ran at all.. coz it doesnt delete the file which is 30 days older
---------- Post updated at 05:28 PM ---------- Previous update was at 05:21 PM ----------
@ methyl : i dont understand wat u r saying.. as am a newbie to Unix.. Could u kindly convey message simply as i could understand.. Sorry, I think u could understand.. Thanks for Understanding
---------- Post updated at 05:33 PM ---------- Previous update was at 05:28 PM ----------
Inside the path
/var/spool/mail/root
The cronjob results showed as below
/bin/sh: /ask/tarballs/tar1.sh: Permission denied
Why is this so..?? could u please help me with that
If you were logged in as "root" then the cron is owned by root.
#To find out your Operating System and version:
uname -a
#To find out your normal Shell
echo $SHELL
The mail file is a text file. You can read it with "more" or "tail". In your case at 12:01 GMT you should find it quite easily:
tail -200 /var/spool/mail/root | more
There are proper ways of reading the mail but we are probably just looking for an error message or other output from your cron.
The permissions of the script file are important. It must be executable by the owner of the cron.
ls -ald /ask/tarballs/tar1.sh
(POSTS CROSSED)
You need to make the script file executable.
chmod 755 /ask/tarballs/tar1.sh
Also note that the error message in your post came from /bin/sh which is the default Shell from cron.
If the default Shell from your user is different you will need a shebang line at the top of your script.
This will indeed work providing that the messages come from the script and not from cron itself. The problem error from post #1 would still come out in root mail.
Personally I would put the logfile redirect inside the script and keep crontab as uncluttered as possible.
Cronjob is working now actually. But the problem i got now is,
Actually while running the script tar1.sh as a cronjob, only the else part is running.
i.e
Directory size doesnt exceed Threshold Limit
even though size is greater than size1
but when we execute the script as sh tar1.sh, its deleting the expected files
so wat could be the problem..?? could u please help me with this..?