1

Is it possible to make a script run a command in another users (user1) screen session that has been started by a script ran by a normal user (user1)? For example, a script run by root directing a command to a screen session owned by user1

Preface

I have a script for a game server that backs up important files of the server using rdiff-backup. I wanted to run the script as root and have the backups in the /root/ directory to offer software protection to the backups in case some software or user error occurs with the server.

The problem is that the script needed to send some commands to the console of the game server before starting the rdiff-backup

Actual problem

I needed a script run as root that has multiple lines like this:

as_user "screen -p 0 -S ${SCREENNAME} -X eval 'stuff \"say ${SAY_BACKUP_START}\"\015'"

to send the commands to a screen session that was owned by user1 and started from a script run by a cronjob owner by user1

Is this possible or would it just be easier to run the backups as user1 and keep the files in the user1 home directory and just have another rdiff-backup run by root to back up the backed up files to a soft protected directory?

  • Have you tried using su to run the command as user1? – G-Man Jun 6 '18 at 19:49
  • What about running the script as user1 and using sudo to save to the /root directory? – Jesse_b Jun 7 '18 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.