Starting script in screen with cronsend command to an already running screen sessionrm failing inside cron...

What is the best way to simulate grief?

How can animals be objects of ethics without being subjects as well?

Why do neural networks need so many training examples to perform?

Number of FLOP (Floating Point Operations) for exponentiation

When does coming up with an idea constitute sufficient contribution for authorship?

Are there any monsters that consume a player character?

Could flying insects re-enter the Earth's atmosphere from space without burning up?

How should I handle players who ignore the session zero agreement?

How to remove trailing forward slash

Quenching swords in dragon blood; why?

What is the time complexity of enqueue and dequeue of a queue implemented with a singly linked list?

Can polymorphing monsters spam their ability to effectively give themselves a massive health pool?

Why did the villain in the first Men in Black movie care about Earth's Cockroaches?

Please help me understand the following solution

Manipulating a general length function

Word or phrase for showing great skill at something without formal training in it

Compound Interest... with Wizard Money

Issues with new Macs: Hardware makes them difficult for me to use. What options might be available in the future?

Using only 1s, make 29 with the minimum number of digits

What is the purpose of easy combat scenarios that don't need resource expenditure?

Does Windows 10's telemetry include sending *.doc files if Word crashed?

Why avoid shared user accounts?

Everyone is beautiful

Closed form for these polynomials?



Starting script in screen with cron


send command to an already running screen sessionrm failing inside cron scriptCron Job that Boots Screen at StartStarting program on boot with screenScript acts differently whe run by cronCron fails the script commandIssues running ruby script as cron jobMany cron -f processes on unresponsive serverIncron Won't Execute a Script But Cron Will, Permission Deniedcron job not running bash scriptcron job not running /bin/bash: user: command not found













1















I apologise if this has been asked before but I am not sure how to question a search query for this.
I am extremely new to linux and I have been learning as I go to solve issues.



I am trying to set up working cron jobs to restart a game server I am running.



Currently my crontab looks like this



#backup world as instructed by https://github.com/g1franc/SEDS-Setup
0 0 * * * /home/root/spaceengineers/start.sh backupworld
#close server
1 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^C"
#close screen
2 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^M"
#recreate server
3 0 * * * /home/root/spaceengineers/start.sh


Now on the backup world I get in my syslog file located at /var/log i get



May 24 00:00:01 SpaceEngineers CRON[1958]: (root) CMD (/home/root/spaceengineers/start.sh backupworld)
May 24 00:00:01 SpaceEngineers CRON[1957]: (CRON) info (No MTA installed, discarding output)


and that is also the same with the recreate server



May 24 00:03:01 SpaceEngineers CRON[2269]: (root) CMD (/home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers)
May 24 00:03:01 SpaceEngineers CRON[2268]: (CRON) info (No MTA installed, discarding output)


The other commands work perfectly fine.



now before anyone questions why I have structured my code the way I have, its because the tutorial i was following says to start the server via ~/spaceengineers/start.sh -x spaceengineers
and from what I have read i need to do /usr/bin/screen to access any screen commands in Cron



What am I doing wrong and what do I need to do to rectify my issues.



EDITED: Changed the crontab to match current contents on my server, issues remain the same



Pastebin of start.sh



http://pastebin.com/9QcWyqYF










share|improve this question
















bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    The message about MTA is happening because CRON tries to send email on job completion. It can be safely ignored, unless you want the job output to be sent via email. Are the two problematic jobs actually running as expected? Do they do what you want?

    – boot13
    May 23 '15 at 17:33











  • @boot13 Just rechecked and the backup script seems to be doing something now but the recreate server job is not doing anything

    – TheAngryBr1t
    May 23 '15 at 17:40











  • Can you add the relevant bits from the start scriot

    – fswings
    May 24 '15 at 0:24
















1















I apologise if this has been asked before but I am not sure how to question a search query for this.
I am extremely new to linux and I have been learning as I go to solve issues.



I am trying to set up working cron jobs to restart a game server I am running.



Currently my crontab looks like this



#backup world as instructed by https://github.com/g1franc/SEDS-Setup
0 0 * * * /home/root/spaceengineers/start.sh backupworld
#close server
1 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^C"
#close screen
2 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^M"
#recreate server
3 0 * * * /home/root/spaceengineers/start.sh


Now on the backup world I get in my syslog file located at /var/log i get



May 24 00:00:01 SpaceEngineers CRON[1958]: (root) CMD (/home/root/spaceengineers/start.sh backupworld)
May 24 00:00:01 SpaceEngineers CRON[1957]: (CRON) info (No MTA installed, discarding output)


and that is also the same with the recreate server



May 24 00:03:01 SpaceEngineers CRON[2269]: (root) CMD (/home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers)
May 24 00:03:01 SpaceEngineers CRON[2268]: (CRON) info (No MTA installed, discarding output)


The other commands work perfectly fine.



now before anyone questions why I have structured my code the way I have, its because the tutorial i was following says to start the server via ~/spaceengineers/start.sh -x spaceengineers
and from what I have read i need to do /usr/bin/screen to access any screen commands in Cron



What am I doing wrong and what do I need to do to rectify my issues.



EDITED: Changed the crontab to match current contents on my server, issues remain the same



Pastebin of start.sh



http://pastebin.com/9QcWyqYF










share|improve this question
















bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    The message about MTA is happening because CRON tries to send email on job completion. It can be safely ignored, unless you want the job output to be sent via email. Are the two problematic jobs actually running as expected? Do they do what you want?

    – boot13
    May 23 '15 at 17:33











  • @boot13 Just rechecked and the backup script seems to be doing something now but the recreate server job is not doing anything

    – TheAngryBr1t
    May 23 '15 at 17:40











  • Can you add the relevant bits from the start scriot

    – fswings
    May 24 '15 at 0:24














1












1








1








I apologise if this has been asked before but I am not sure how to question a search query for this.
I am extremely new to linux and I have been learning as I go to solve issues.



I am trying to set up working cron jobs to restart a game server I am running.



Currently my crontab looks like this



#backup world as instructed by https://github.com/g1franc/SEDS-Setup
0 0 * * * /home/root/spaceengineers/start.sh backupworld
#close server
1 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^C"
#close screen
2 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^M"
#recreate server
3 0 * * * /home/root/spaceengineers/start.sh


Now on the backup world I get in my syslog file located at /var/log i get



May 24 00:00:01 SpaceEngineers CRON[1958]: (root) CMD (/home/root/spaceengineers/start.sh backupworld)
May 24 00:00:01 SpaceEngineers CRON[1957]: (CRON) info (No MTA installed, discarding output)


and that is also the same with the recreate server



May 24 00:03:01 SpaceEngineers CRON[2269]: (root) CMD (/home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers)
May 24 00:03:01 SpaceEngineers CRON[2268]: (CRON) info (No MTA installed, discarding output)


The other commands work perfectly fine.



now before anyone questions why I have structured my code the way I have, its because the tutorial i was following says to start the server via ~/spaceengineers/start.sh -x spaceengineers
and from what I have read i need to do /usr/bin/screen to access any screen commands in Cron



What am I doing wrong and what do I need to do to rectify my issues.



EDITED: Changed the crontab to match current contents on my server, issues remain the same



Pastebin of start.sh



http://pastebin.com/9QcWyqYF










share|improve this question
















I apologise if this has been asked before but I am not sure how to question a search query for this.
I am extremely new to linux and I have been learning as I go to solve issues.



I am trying to set up working cron jobs to restart a game server I am running.



Currently my crontab looks like this



#backup world as instructed by https://github.com/g1franc/SEDS-Setup
0 0 * * * /home/root/spaceengineers/start.sh backupworld
#close server
1 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^C"
#close screen
2 0 * * * /usr/bin/screen -S spaceengineers -X stuff "^M"
#recreate server
3 0 * * * /home/root/spaceengineers/start.sh


Now on the backup world I get in my syslog file located at /var/log i get



May 24 00:00:01 SpaceEngineers CRON[1958]: (root) CMD (/home/root/spaceengineers/start.sh backupworld)
May 24 00:00:01 SpaceEngineers CRON[1957]: (CRON) info (No MTA installed, discarding output)


and that is also the same with the recreate server



May 24 00:03:01 SpaceEngineers CRON[2269]: (root) CMD (/home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers)
May 24 00:03:01 SpaceEngineers CRON[2268]: (CRON) info (No MTA installed, discarding output)


The other commands work perfectly fine.



now before anyone questions why I have structured my code the way I have, its because the tutorial i was following says to start the server via ~/spaceengineers/start.sh -x spaceengineers
and from what I have read i need to do /usr/bin/screen to access any screen commands in Cron



What am I doing wrong and what do I need to do to rectify my issues.



EDITED: Changed the crontab to match current contents on my server, issues remain the same



Pastebin of start.sh



http://pastebin.com/9QcWyqYF







linux bash gnu-screen cron






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 24 '15 at 0:25







TheAngryBr1t

















asked May 23 '15 at 17:11









TheAngryBr1tTheAngryBr1t

63




63





bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1





    The message about MTA is happening because CRON tries to send email on job completion. It can be safely ignored, unless you want the job output to be sent via email. Are the two problematic jobs actually running as expected? Do they do what you want?

    – boot13
    May 23 '15 at 17:33











  • @boot13 Just rechecked and the backup script seems to be doing something now but the recreate server job is not doing anything

    – TheAngryBr1t
    May 23 '15 at 17:40











  • Can you add the relevant bits from the start scriot

    – fswings
    May 24 '15 at 0:24














  • 1





    The message about MTA is happening because CRON tries to send email on job completion. It can be safely ignored, unless you want the job output to be sent via email. Are the two problematic jobs actually running as expected? Do they do what you want?

    – boot13
    May 23 '15 at 17:33











  • @boot13 Just rechecked and the backup script seems to be doing something now but the recreate server job is not doing anything

    – TheAngryBr1t
    May 23 '15 at 17:40











  • Can you add the relevant bits from the start scriot

    – fswings
    May 24 '15 at 0:24








1




1





The message about MTA is happening because CRON tries to send email on job completion. It can be safely ignored, unless you want the job output to be sent via email. Are the two problematic jobs actually running as expected? Do they do what you want?

– boot13
May 23 '15 at 17:33





The message about MTA is happening because CRON tries to send email on job completion. It can be safely ignored, unless you want the job output to be sent via email. Are the two problematic jobs actually running as expected? Do they do what you want?

– boot13
May 23 '15 at 17:33













@boot13 Just rechecked and the backup script seems to be doing something now but the recreate server job is not doing anything

– TheAngryBr1t
May 23 '15 at 17:40





@boot13 Just rechecked and the backup script seems to be doing something now but the recreate server job is not doing anything

– TheAngryBr1t
May 23 '15 at 17:40













Can you add the relevant bits from the start scriot

– fswings
May 24 '15 at 0:24





Can you add the relevant bits from the start scriot

– fswings
May 24 '15 at 0:24










3 Answers
3






active

oldest

votes


















0














Can you check the GNU screen syntax for this line:



3 0 * * * /home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers


I would've expected something like:



3 0 * * * /usr/bin/screen -S spaceengineers -X stuff 'command with newline' 


However, using the -X means screen expects screen commands and not a script to run.



Therefore you need to use the screen stuff command as per this SU question



screen -S sessionname -X stuff 'command'`echo -ne '15'`


Update



Try /bin/bash or wherever the Shell you use is located.



 3 0 * * * /bin/bash /home/root/spaceengineers/start.sh


Maybe add contents of start.sh to help debug.



You can find shell with the which command. Might have to sudo or be root to find out.






share|improve this answer


























  • I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

    – TheAngryBr1t
    May 23 '15 at 23:18













  • In my crontab had to specify the Shell location.

    – fswings
    May 23 '15 at 23:41











  • I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

    – TheAngryBr1t
    May 24 '15 at 0:22













  • The script may have to be modified so it uses absolute paths.

    – fswings
    May 24 '15 at 0:23











  • pastebin.com/9QcWyqYF here is pastebin of code

    – TheAngryBr1t
    May 24 '15 at 0:26



















0














This command worked for me, though because one or more of the commands in my script required sudo, I had to set this up under the root user's cron :



17 2 29 1 * /usr/bin/screen -dmS $MYSESSIONNAME /bin/bash $FULLPATHTOMYSHELLSCRIPT $SHELLSCRIPTARG1 $SHELLSCRIPTARG2 ...



The key to getting screen working (and not just closing immediately when invoked by cron) is the -d argument, but the m probably helps too in some way/cases.



Below is the relevant snippet from the screen --help output



"-dmS name Start as daemon: Screen session in detached mode."






share|improve this answer































    -1














    @daily /usr/bin/screen -dms aquaticscenery /ig.py && python ig.py






    share|improve this answer



















    • 5





      Can you explain this command? :)

      – bertieb
      Apr 19 '17 at 13:37








    • 1





      This may be a correct solution but please explain a bit more of how this solves the question asker's question

      – Eric F
      Apr 19 '17 at 16:11











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f918677%2fstarting-script-in-screen-with-cron%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Can you check the GNU screen syntax for this line:



    3 0 * * * /home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers


    I would've expected something like:



    3 0 * * * /usr/bin/screen -S spaceengineers -X stuff 'command with newline' 


    However, using the -X means screen expects screen commands and not a script to run.



    Therefore you need to use the screen stuff command as per this SU question



    screen -S sessionname -X stuff 'command'`echo -ne '15'`


    Update



    Try /bin/bash or wherever the Shell you use is located.



     3 0 * * * /bin/bash /home/root/spaceengineers/start.sh


    Maybe add contents of start.sh to help debug.



    You can find shell with the which command. Might have to sudo or be root to find out.






    share|improve this answer


























    • I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

      – TheAngryBr1t
      May 23 '15 at 23:18













    • In my crontab had to specify the Shell location.

      – fswings
      May 23 '15 at 23:41











    • I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

      – TheAngryBr1t
      May 24 '15 at 0:22













    • The script may have to be modified so it uses absolute paths.

      – fswings
      May 24 '15 at 0:23











    • pastebin.com/9QcWyqYF here is pastebin of code

      – TheAngryBr1t
      May 24 '15 at 0:26
















    0














    Can you check the GNU screen syntax for this line:



    3 0 * * * /home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers


    I would've expected something like:



    3 0 * * * /usr/bin/screen -S spaceengineers -X stuff 'command with newline' 


    However, using the -X means screen expects screen commands and not a script to run.



    Therefore you need to use the screen stuff command as per this SU question



    screen -S sessionname -X stuff 'command'`echo -ne '15'`


    Update



    Try /bin/bash or wherever the Shell you use is located.



     3 0 * * * /bin/bash /home/root/spaceengineers/start.sh


    Maybe add contents of start.sh to help debug.



    You can find shell with the which command. Might have to sudo or be root to find out.






    share|improve this answer


























    • I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

      – TheAngryBr1t
      May 23 '15 at 23:18













    • In my crontab had to specify the Shell location.

      – fswings
      May 23 '15 at 23:41











    • I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

      – TheAngryBr1t
      May 24 '15 at 0:22













    • The script may have to be modified so it uses absolute paths.

      – fswings
      May 24 '15 at 0:23











    • pastebin.com/9QcWyqYF here is pastebin of code

      – TheAngryBr1t
      May 24 '15 at 0:26














    0












    0








    0







    Can you check the GNU screen syntax for this line:



    3 0 * * * /home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers


    I would've expected something like:



    3 0 * * * /usr/bin/screen -S spaceengineers -X stuff 'command with newline' 


    However, using the -X means screen expects screen commands and not a script to run.



    Therefore you need to use the screen stuff command as per this SU question



    screen -S sessionname -X stuff 'command'`echo -ne '15'`


    Update



    Try /bin/bash or wherever the Shell you use is located.



     3 0 * * * /bin/bash /home/root/spaceengineers/start.sh


    Maybe add contents of start.sh to help debug.



    You can find shell with the which command. Might have to sudo or be root to find out.






    share|improve this answer















    Can you check the GNU screen syntax for this line:



    3 0 * * * /home/root/spaceengineers/start.sh /usr/bin/screen -x spaceengineers


    I would've expected something like:



    3 0 * * * /usr/bin/screen -S spaceengineers -X stuff 'command with newline' 


    However, using the -X means screen expects screen commands and not a script to run.



    Therefore you need to use the screen stuff command as per this SU question



    screen -S sessionname -X stuff 'command'`echo -ne '15'`


    Update



    Try /bin/bash or wherever the Shell you use is located.



     3 0 * * * /bin/bash /home/root/spaceengineers/start.sh


    Maybe add contents of start.sh to help debug.



    You can find shell with the which command. Might have to sudo or be root to find out.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 20 '17 at 10:16









    Community

    1




    1










    answered May 23 '15 at 22:50









    fswingsfswings

    514423




    514423













    • I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

      – TheAngryBr1t
      May 23 '15 at 23:18













    • In my crontab had to specify the Shell location.

      – fswings
      May 23 '15 at 23:41











    • I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

      – TheAngryBr1t
      May 24 '15 at 0:22













    • The script may have to be modified so it uses absolute paths.

      – fswings
      May 24 '15 at 0:23











    • pastebin.com/9QcWyqYF here is pastebin of code

      – TheAngryBr1t
      May 24 '15 at 0:26



















    • I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

      – TheAngryBr1t
      May 23 '15 at 23:18













    • In my crontab had to specify the Shell location.

      – fswings
      May 23 '15 at 23:41











    • I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

      – TheAngryBr1t
      May 24 '15 at 0:22













    • The script may have to be modified so it uses absolute paths.

      – fswings
      May 24 '15 at 0:23











    • pastebin.com/9QcWyqYF here is pastebin of code

      – TheAngryBr1t
      May 24 '15 at 0:26

















    I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

    – TheAngryBr1t
    May 23 '15 at 23:18







    I have just removed the usr/bin/screen stuff as it is no longer needed. turns out the script is creating a screen by itself, I believe that to be when running a program through WINE. as I said I am learning on the fly. But with this stuff now removed the script is still not executing. the recreate server line now reads: 3 0 * * * /home/root/spaceengineers/start.sh The reason I have changed it to that is the backup script is working and its called the same way. have edited the question with the new crontab

    – TheAngryBr1t
    May 23 '15 at 23:18















    In my crontab had to specify the Shell location.

    – fswings
    May 23 '15 at 23:41





    In my crontab had to specify the Shell location.

    – fswings
    May 23 '15 at 23:41













    I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

    – TheAngryBr1t
    May 24 '15 at 0:22







    I added /bin/bash after checking what shell I am using and making sure i had my Crontabs SHELL path set to SHELL=/bin/bash I am still not getting anywhere. I have made sure the shebang in the script is set correctly as well. UPDATE: Finally seeing in the syslog that it is trying to run commands. For the last 2 hours I wasnt getting anything in the log. May 24 00:03:01 SpaceEngineers CRON[2594]: (root) CMD (/bin/bash /home/root/spaceengineers/start.sh) It still is not actually creating the screen like it normally does if run manually, but i guess its a step forward.

    – TheAngryBr1t
    May 24 '15 at 0:22















    The script may have to be modified so it uses absolute paths.

    – fswings
    May 24 '15 at 0:23





    The script may have to be modified so it uses absolute paths.

    – fswings
    May 24 '15 at 0:23













    pastebin.com/9QcWyqYF here is pastebin of code

    – TheAngryBr1t
    May 24 '15 at 0:26





    pastebin.com/9QcWyqYF here is pastebin of code

    – TheAngryBr1t
    May 24 '15 at 0:26













    0














    This command worked for me, though because one or more of the commands in my script required sudo, I had to set this up under the root user's cron :



    17 2 29 1 * /usr/bin/screen -dmS $MYSESSIONNAME /bin/bash $FULLPATHTOMYSHELLSCRIPT $SHELLSCRIPTARG1 $SHELLSCRIPTARG2 ...



    The key to getting screen working (and not just closing immediately when invoked by cron) is the -d argument, but the m probably helps too in some way/cases.



    Below is the relevant snippet from the screen --help output



    "-dmS name Start as daemon: Screen session in detached mode."






    share|improve this answer




























      0














      This command worked for me, though because one or more of the commands in my script required sudo, I had to set this up under the root user's cron :



      17 2 29 1 * /usr/bin/screen -dmS $MYSESSIONNAME /bin/bash $FULLPATHTOMYSHELLSCRIPT $SHELLSCRIPTARG1 $SHELLSCRIPTARG2 ...



      The key to getting screen working (and not just closing immediately when invoked by cron) is the -d argument, but the m probably helps too in some way/cases.



      Below is the relevant snippet from the screen --help output



      "-dmS name Start as daemon: Screen session in detached mode."






      share|improve this answer


























        0












        0








        0







        This command worked for me, though because one or more of the commands in my script required sudo, I had to set this up under the root user's cron :



        17 2 29 1 * /usr/bin/screen -dmS $MYSESSIONNAME /bin/bash $FULLPATHTOMYSHELLSCRIPT $SHELLSCRIPTARG1 $SHELLSCRIPTARG2 ...



        The key to getting screen working (and not just closing immediately when invoked by cron) is the -d argument, but the m probably helps too in some way/cases.



        Below is the relevant snippet from the screen --help output



        "-dmS name Start as daemon: Screen session in detached mode."






        share|improve this answer













        This command worked for me, though because one or more of the commands in my script required sudo, I had to set this up under the root user's cron :



        17 2 29 1 * /usr/bin/screen -dmS $MYSESSIONNAME /bin/bash $FULLPATHTOMYSHELLSCRIPT $SHELLSCRIPTARG1 $SHELLSCRIPTARG2 ...



        The key to getting screen working (and not just closing immediately when invoked by cron) is the -d argument, but the m probably helps too in some way/cases.



        Below is the relevant snippet from the screen --help output



        "-dmS name Start as daemon: Screen session in detached mode."







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 29 at 7:33









        Jack HadleyJack Hadley

        212




        212























            -1














            @daily /usr/bin/screen -dms aquaticscenery /ig.py && python ig.py






            share|improve this answer



















            • 5





              Can you explain this command? :)

              – bertieb
              Apr 19 '17 at 13:37








            • 1





              This may be a correct solution but please explain a bit more of how this solves the question asker's question

              – Eric F
              Apr 19 '17 at 16:11
















            -1














            @daily /usr/bin/screen -dms aquaticscenery /ig.py && python ig.py






            share|improve this answer



















            • 5





              Can you explain this command? :)

              – bertieb
              Apr 19 '17 at 13:37








            • 1





              This may be a correct solution but please explain a bit more of how this solves the question asker's question

              – Eric F
              Apr 19 '17 at 16:11














            -1












            -1








            -1







            @daily /usr/bin/screen -dms aquaticscenery /ig.py && python ig.py






            share|improve this answer













            @daily /usr/bin/screen -dms aquaticscenery /ig.py && python ig.py







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 19 '17 at 13:12









            Danik SokilDanik Sokil

            1




            1








            • 5





              Can you explain this command? :)

              – bertieb
              Apr 19 '17 at 13:37








            • 1





              This may be a correct solution but please explain a bit more of how this solves the question asker's question

              – Eric F
              Apr 19 '17 at 16:11














            • 5





              Can you explain this command? :)

              – bertieb
              Apr 19 '17 at 13:37








            • 1





              This may be a correct solution but please explain a bit more of how this solves the question asker's question

              – Eric F
              Apr 19 '17 at 16:11








            5




            5





            Can you explain this command? :)

            – bertieb
            Apr 19 '17 at 13:37







            Can you explain this command? :)

            – bertieb
            Apr 19 '17 at 13:37






            1




            1





            This may be a correct solution but please explain a bit more of how this solves the question asker's question

            – Eric F
            Apr 19 '17 at 16:11





            This may be a correct solution but please explain a bit more of how this solves the question asker's question

            – Eric F
            Apr 19 '17 at 16:11


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f918677%2fstarting-script-in-screen-with-cron%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...