LinuxQuestions.org
Weather apps tell you it'll rain. Wyndo tells you when to go.
Home Forums Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-25-2025, 08:58 PM   #1
HowieL
LQ Newbie
 
Registered: Sep 2024
Posts: 19

Rep: Reputation: 0
Does crontab understand about symlinks?


Setup: Debian 12 on an RPi4 hosting a couple of low traffic websites thru a publically visible static IP.
I use Lets Encrypt and .acme.sh running as root from the /root directory to regularly regenerate my SSL certificates for my websites.
I also have /usr/bin/apachectl symlinked into the /root directory so that .acme.sh can set the certificates for apache2 to use, and I have all of this set up in a bash script.
When I run the bash script in the foreground it all runs as expected and the certificates are regenerated and apachectl sets them in place.
The problem comes when I want to run this bash script in a crontab; the certificates are regenerated without problem but the crontab complains that it can't find apachectl. Consequently the certificates are not set into place.
My assumption is that crontab doesn't know about symlinks.
Should I be hardlinking /usr/bin/apachectl into /root, and are there any adverse consequences as a result? I don't need to make this hard
link permanent but could include it in the bash script and delete it at the end of the script.
The bash script:

Code:
raspi-dmz:~# cat dmz.d/ssl.sh 
S=raspi-dmz
D=acme-domain
H=EXAMPLE.COM
P=mosquitto_pub
Q=2
T=ssl
I=upgrade
M=''
~/.acme.sh/acme.sh --upgrade 2>~/_$D\.err
E=$?
if [ $E -ne '0' ]
	then M=FAILED
fi
echo ''
$P -h $H -t $T/$I -m "$E '$I' $M" -q $Q
for I in $(cat ~/$D); do
	M=''
	~/.acme.sh/acme.sh --domain $I --renew 2>>~/_$D\.err
	E=$?
	case $E in
		'2')
			M=SKIPPED
			;;
		'1')
			M=FAILED
			;;
		'0')
			M=INSTALLED
			;;
		*)
			M=EXIT_UNK
			;;
	esac
	echo ''
	$P -h $H -t $T/$D -m "$E '$I' $M" -q $Q
done
 
Old 07-25-2025, 09:10 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 20,519
Blog Entries: 28

Rep: Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573Reputation: 6573
This cron man page may answer your question. See the section headed "Caveats."
 
Old 07-26-2025, 12:07 AM   #3
lvm_
Senior Member
 
Registered: Jul 2020
Posts: 1,880

Rep: Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637
Quote:
Originally Posted by HowieL View Post
My assumption is that crontab doesn't know about symlinks.
Obviously, it doesn't have to - it's filesystem's job. I bet you problem is, as always, with cron running in it's own environment which is different from that of regular user. Set environment variables as needed, use shebang in scripts to define interpreters explicitly, and it will work.
 
Old 07-26-2025, 09:20 PM   #4
HowieL
LQ Newbie
 
Registered: Sep 2024
Posts: 19

Original Poster
Rep: Reputation: 0
[SOLVED]

Check the PATH variable. Duh!
 
  


Reply

Tags
crontab, symlink



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gdrive from crontab does'nt work , shell is ok from command line but failed from crontab sazdovskij Linux - Newbie 3 05-20-2019 12:25 PM
[SOLVED] crontab does not reread the crontab file upon modification of the latter. stf92 Slackware 4 08-01-2015 06:12 PM
[SOLVED] Trying to understand how Mutt and Crontab works hahnhahnhahn Linux - General 2 01-08-2014 11:41 PM
help me understand the difference between cron.daily and crontab -e duderancher Linux - Software 7 10-09-2008 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:07 PM.

Contact Us - Advertising Info - Rules - Privacy - Donations - Contributing Member - LQ Sitemap - "Weather apps tell you it'll rain. Wyndo tells you when to go."
Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions