i know that this question has bin asked & answered a lot of times and i think i have read all of them :-( but still don't got it working :-(
OK, using CentOS release 8.2.2004 (Core) in root's cron i call a script
*/1 * * * * /bin/bash /home/getSSHsessions.sh the script just creates a file with some process listing
[root@myhost]# cat /home/getSSHsessions.sh #!/bin/bash /usr/bin/netstat -tnpa | /usr/bin/grep "VERBUNDEN.*sshd" > /mnt/ramdisk/sshsession.ls but the output is just a empty file
[root@myhost]# ll /mnt/ramdisk/ -rw-r--r--. 1 root root 0 5. Okt 19:33 sshsession.ls I get crazy about that. Really don't know any more where to look.
Ah, yes, the script works fine run as user root on cmd-line. Then it creates the output as it should.
[root@myhost]# cat /home/getSSHsessions.sh #!/bin/bash /usr/bin/netstat -tnpa | /usr/bin/grep "VERBUNDEN.*sshd" > /mnt/ramdisk/sshsession.ls [root@saprouter iteanova]# /home/getSSHsessions.sh [root@myhost]# ll /mnt/ramdisk/ -rw-r--r--. 1 root root 404 6. Okt 10:46 sshsession.ls [root@myhost]# cat /mnt/ramdisk/sshsession.ls tcp 0 0 192.168.137.4:54782 192.168.137.2:80 VERBUNDEN 309654/sshd: myuser tcp 0 0 192.168.137.4:22 95.208.219.123:33300 VERBUNDEN 309622/sshd: myuser tcp 0 0 192.168.137.4:22 95.208.219.123:60744 VERBUNDEN 308085/sshd: myuser tcp 0 0 192.168.137.4:22 35.203.68.135:36564 VERBUNDEN 310513/sshd: root [