How to automatically run a script after user login

Hello,

I want to know how to automatically run a script after user login.
I placed my script at the /etc/profile. d/ , but it did not run
 
Do you want to make a daemon or a script in bash?
As in Bash, use /etc/crontab

Code:
# Rotate log files every hour, if necessary.
0       *       *       *       *       root    newsyslog
#
# Perform daily/weekly/monthly maintenance.
1       3       *       *       *       root    periodic daily
15      4       *       *       6       root    periodic weekly
30      5       1       *       *       root    periodic monthly
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time.  See adjkerntz(8) for details.
1,31    0-5     *       *       *       root    adjkerntz -a

@reboot root /bin/sh /root/syncthing.sh

Where /root/syncthing.sh - is your bash script.
 
You can use ~/.ssh/rc or /etc/ssh/sshrc to execute script in user shell independent way.

man 8 sshd
man 5 sshd_config


Enjoy.
 
Last edited:
Back
Top