- Products
- Learn
- Local User Groups
- Partners
- More
Quantum Spark Management Unleashed!
Check Point Named Leader
2025 Gartner® Magic Quadrant™ for Hybrid Mesh Firewall
HTTPS Inspection
Help us to understand your needs better
CheckMates Go:
SharePoint CVEs and More!
Hello
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.
Hi Dameon
No errors at all in /var/log/cron. any other file i should be looking at?
Regards
Are you explicitly declaring the command interpreter (i.e. magic number) at the start of the shell script like this:
#!/bin/bash -f
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"
Hi Luis
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.
Refer to:
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:
#!/bin/sh
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/bash
MAILTO=""
#
# mins hrs daysinm months daysinw command
#
##MDS_backup
00 1 * * * /backup/scripts/FWBackupMDS >/dev/null 2>&1
How to add crontab job for interface link status down or up and send mail if link is down.
@Ignacio Garcia: I am not sure if the problem was resolved?
When a script doesn't run as a cronjob, then the reason is almost always one of three things:
1) The cronjob user does not have the Bash shell set as default, or
2) the CP environment parameters is not loading correctly.
3) On rare occations I have experienced that one must run the command "dos2unix *.sh" to get the cronjob working.
I recently discovered that sk77300 is no longer correct.
Changing the <version> parameter to R80 only works with R80 and R80.10source /opt/CPshrd-R80/tmp/.CPprofile.sh
When using R80.20 it must look like this:source /opt/CPshrd-R80.20/tmp/.CPprofile.sh
Hope this helps! :smileyhappy:
I found that if you add the -l flag to your shebang:
#!/bin/bash -l
Things behave w/in crontab in a more expected fashion.
From 'man bash':
-l Make bash act as if it had been invoked as a login shell (see INVOCATION below)
Leaderboard
Epsum factorial non deposit quid pro quo hic escorol.
User | Count |
---|---|
9 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 |
Thu 18 Sep 2025 @ 03:00 PM (CEST)
Bridge the Unmanaged Device Gap with Enterprise Browser - EMEAThu 18 Sep 2025 @ 02:00 PM (EDT)
Bridge the Unmanaged Device Gap with Enterprise Browser - AmericasMon 22 Sep 2025 @ 03:00 PM (CEST)
Defending Hyperconnected AI-Driven Networks with Hybrid Mesh Security EMEAMon 22 Sep 2025 @ 02:00 PM (EDT)
Defending Hyperconnected AI-Driven Networks with Hybrid Mesh Security AMERThu 18 Sep 2025 @ 03:00 PM (CEST)
Bridge the Unmanaged Device Gap with Enterprise Browser - EMEAThu 18 Sep 2025 @ 02:00 PM (EDT)
Bridge the Unmanaged Device Gap with Enterprise Browser - AmericasMon 22 Sep 2025 @ 03:00 PM (CEST)
Defending Hyperconnected AI-Driven Networks with Hybrid Mesh Security EMEAAbout CheckMates
Learn Check Point
Advanced Learning
YOU DESERVE THE BEST SECURITY