I'm trying to scheddule a cronjob (bash script) in our management station. Such bash script, when executed manually, works flawlesly, but when scheduled over cron, it does not work. sk77300 and sk90441 have not helped at all.
Any other ideas?
1. Please check if cron daemon is running.
2. Please check if your script ends with the newline.
Keep in mind some environment variables in the script may not be defined in the environment that runs the cron script.
It would be helpful if you could provide the errors you're getting.
No errors at all in /var/log/cron. any other file i should be looking at?
Are you explicitly declaring the command interpreter (i.e. magic number) at the start of the shell script like this:
If so, try adding -x like this:
#!/bin/bash -f -x
-x causes every command being executed by the script and its arguments to be output as it happens. Very helpful for troubleshooting. Also make sure that any commands being invoked in the script are using absolute paths (i.e. /bin/ls) and try to avoid using relative paths and paths referencing an environment variable such as $FWDIR/bin/ until you figure out what is wrong.
-- My book "Max Power: Check Point Firewall Performance Optimization" now available via http://maxpowerfirewalls.com.
If you need to load the environment variables: "source /etc/profile.d/CP.sh"
The line is in the script.
@Tim: Those options are not recognized:
/bin/bash: - : invalid option
I had $MDSVERUTIL in my script, which i exchanged with /opt/CPmds-R77/system/shared/MDSVerUtil. Situation is still the same when script is run over Cron (which is active), and running it manually gives no problem
What errors do you get? Make sure you sent the output of the script execution to a file where you can see the errors
Not sure if this helps... Be sure to write the full path of all commands into cron and/or script invoked.
difference between cron and command line environment? shell script errors
The below produces no out put at all:
*/5 * * * * /home/indeni/wf_session_check.sh >> /home/indeni/session.txt 2>&1
As which user are you adding this crontab job?
Does that use have sufficient access rights?
Keep in minds we have zero knowledge of what you have done or what your setup looks like. Unless you tell us we simply don't know.
Can you show us the script?
What "source" line do you use?
If you see nothing at /home/indeni/session.txt it is probably because cron is not running your script.
This is how we run scripts from cron, in clish add the following command:
add cron job MDS_backup command "/backup/scripts/FWBackupMDS >/dev/null 2>&1" recurrence daily time 1:00
The >/dev/null 2>&1 makes sure the output is redirected properly. On the first line of the script put this line:
After that all other things you need to do.
<crontab -l> shows me:
# This file was AUTOMATICALLY GENERATED# Generated by /bin/cron_xlate on Mon Aug 7 08:42:47 2017# # DO NOT EDIT# SHELL=/bin/bashMAILTO=""## mins hrs daysinm months daysinw command#
##MDS_backup00 1 * * * /backup/scripts/FWBackupMDS >/dev/null 2>&1
Retrieving data ...