Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

Troubleshooting • crontab/script problem

$
0
0
This has got me baffled.
I have a crontab entry that runs a script:

Code:

*/5 * * * * /home/pi/ssh_test.sh
this runs every 5 mins as expected.
The script ssh_test.sh contains :

Code:

#!/bin/bashcp /home/pi/free_memory /home/pi/free_memory.oldfree -h > /home/pi/free_memorycp /home/pi/ssh_status /home/pi/ssh_status.oldservice ssh status > /home/pi/ssh_statustouch /home/pi/ssh_status_run
which, when run from the command line works fine but when its run by cron /home/pi/ssh_status is an empty file.
If I run service ssh status > /home/pi/ssh_status from the command line it runs properly and produces a file that contains

Code:

● ssh.service - OpenBSD Secure Shell server   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)   Active: active (running) since Sat 2025-08-30 12:00:03 BST; 20min ago     Docs: man:sshd(8)           man:sshd_config(5)  Process: 1088 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 1093 (sshd)    Tasks: 1 (limit: 877)   CGroup: /system.slice/ssh.service           └─1093 /usr/sbin/sshd -DAug 30 12:00:02 raspberrypi systemd[1]: Starting OpenBSD Secure Shell server...Aug 30 12:00:03 raspberrypi sshd[1093]: Server listening on 0.0.0.0 port 22.Aug 30 12:00:03 raspberrypi sshd[1093]: Server listening on :: port 22.Aug 30 12:00:03 raspberrypi systemd[1]: Started OpenBSD Secure Shell server.
Any ideas ?

Statistics: Posted by Wensleydale — Sat Aug 30, 2025 11:21 am



Viewing all articles
Browse latest Browse all 8609

Trending Articles