I would like to run a script at wakeup. So my laptop is sleeping, I open the lid, and the script should run immediately or within the minute after wakeup. This script should run at startup as well, as that is essentially the same situation.  How can I run a cronscript at either wakeup and startup?
119855
MacBook Pro 2010 running OS X Lion.  Is it possible to run scripts on sleep and wake events?  My specific application is that I've got Dropbox-synced Truecrypt volumes that  I regularly use on both my MacBook and iMac. I rarely shut down my MBP since closing the lid is much faster and easier, but this means that I have to remember to dismount my Truecrypt volumes and let them sync back up before closing my MBP. It's trivial enough to script mounting/dismounting of them, but I'd like to go a step further and have these scripts run automatically.
55862
I have a script that checks to see if port 4000 is open and listening, if it is return true, else start a service that also outputs a logfile. The script runs fine if I execute it as a user, but if I add it as a cron it doesn't run. I'm logged in as root, the script is owned by root, the script has executable permissions, and I am running crontab -e as root.   #!/bin/bash if lsof -Pi :4000 -sTCP:LISTEN -t &gt;/dev/null ; then     return 1 else     seoserver -p 4000 start &gt; /var/www/vhosts/domain.com/httpdocs/seoserver.log &amp; fi   And here is my cron  */5     *       *       *       *       /usr/bin/seoStart
109271
I've made a custom directory where I've put a couple of my favourite wallpapers. I made a script which examines this directory, counts the number of PNGs, and then randomly sets one image as a wallpaper. It looks like this:  #!/bin/bash #number of images in wallpaper folder cd $HOME/Favourite\ wallpapers/ numImages=`ls *.png | wc -l`  #randomly chose one number randomNum=$[ ( $RANDOM % $numImages ) + 1 ]  #command to set wallpaper gsettings set org.gnome.desktop.background picture-uri file://$HOME/Favourite\ wallpapers/00$randomNum.png   Now, how can I make this script runs on each login (this is very easy thou) or once a day if not has been already run on login?  The problem is that I often suspend my Ubuntu and then awake it tomorrow morning, so in this case I never log in again. Setting this script as startup job would not help me as, obviously, when awaken from suspend, I never re-log in. I cannot simply set it via cron job as well because in cases when I do log in, the wallpaper would be changed two times a day.  PS. anyone feel free to use this script with cron (just set your own path and filename template or wait for a solution like mine :)
44847
I tried to schedule a command to execute 2 minutes later  at -c "ls -l" now + 2 minutes  It fails with multiple ways  $ echo "open 'Google Chrome' " | at now + 2 minutes job 15 at Mon Oct 29 13:31:42 2018   How could I enable it working?  run "open 'Google Chrome' "  at now + 2 minutes   I tried, it is not working  $ at now  at&gt;ls -l at&gt;^D at&gt; &lt;EOT&gt;  job 18 at Mon Oct 29 15:55:00 2018
31487
I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run.  For the purposes of tasks like setting up environment variables and aliases and printing startup messages (e.g. MOTDs), which startup script is the appropriate place to do these?  What's the difference between putting things in .bashrc, .bash_profile, and .environment?  I've also seen other files such as .login, .bash_login, and .profile; are these ever relevant?  What are the differences in which ones get run when logging in physically, logging in remotely via ssh, and opening a new terminal window?  Are there any significant differences across platforms (including Mac OS X (and its Terminal.app) and Cygwin Bash)?
118805
I am running Debian 7 Wheezy and I need to start some screens on startup as soon as there is a fully functional internet connection. However, not, if the internet connection broke and was connected again. So only on the first functional internet connection after boot.  Could you please post a dummy script for this and tell me where to put it and make it be executed under the given conditions?  The script only needs to start the screen and then terminate but the screen should continue.    EDIT I have already heard of the /etc/network/if-up.d/ folder. But how can I make sure that the script is not executed again if the internet connection is lost and then re-established?
93360
I'm trying to run a command at 10 minutes after 2am every weekday only.  In my launchd .plist file, how can I specify this?    I don't want it to run every 2 hours and 10 minutes, just once every weekday at the specified time.
90849
I have this python script. I'm trying to run it on a crontab, but it isn't working:      from datetime import datetime x="Hello, it is now %s." % datetime.now().strftime('%d-%m-%Y %H:%M:%S') import csv try:     with open('output.csv', 'w+') as csvFile:         writer=csv.writer(csvFile)         writer.writerow(x) finally:     csvFile.close()   The crontab is defined as:  attyan22@LAPTOP-SGBTV53C:~$ crontab -l * * * * * python hello_time.py   attyan22@LAPTOP-SGBTV53C:~$ service crond start crond: unrecognized service   I want to run automatically, but it does not working. This is just test .
63120
I know that almost everything on Windows, like opening any sort of application, can be done from the command prompt or from the Run menu.  How can I put my computer to sleep or shut it down? What is the command for that?
106013
If script is running fine from command line then, why the same script becomes zombie state after running through cron and How you will troubleshoot the same ?  Here following real example :  [root@abc ~]# ps ax | grep Z 23880 ?        Zs     0:00 [checkloadadv.sh] &lt;defunct&gt; 23926 pts/0    S+     0:00 grep Z [root@abc ~]# strace -p 23880 attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted [root@abc ~]# pstree | grep  checkload init-+-crond---crond-+-checkloadadv.sh [root@abc ~]# bash /usr/bin/checkloadadv.sh System Load is OK : 0.05
76130
I have set up a cron job, but for some reason it fails to run during the night. The same job runs fine when i'm running it during the day (i.e. setting up the same job to run in a few minutes and waiting for it to run).  Some logs:  Jun 17 14:04:01 server CRON[20174]: (root) CMD (/home/server/scripts/sync.sh &gt;&gt; /home/server/logs/nightly.log 2&gt;&amp;1) Jun 17 14:12:01 server CRON[20349]: (root) CMD (/home/server/scripts/sync.sh &gt;&gt; /home/server/logs/nightly.log 2&gt;&amp;1) Jun 17 14:23:01 server CRON[20513]: (root) CMD (/home/server/scripts/sync.sh &gt;&gt; /home/server/logs/nightly.log 2&gt;&amp;1) Jun 18 01:00:01 server CRON[25717]: (root) CMD (/home/server/scripts/sync.sh &gt;&gt; /home/server/logs/nightly.log 2&gt;&amp;1) # this runs during the night Jun 18 01:00:01 server CRON[25706]: (CRON) error (grandchild #25717 failed with exit status 2) # doesn't leave anything behind it, not even the nightly.log file - as though the command itself is invalid)   cron entry looks like this:  0 1 * * * /home/server/scripts/sync.sh &gt;&gt; /home/server/logs/nightly.log 2&gt;&amp;1   script looks like this:  #!/bin/bash  SUCCESS=0 echo "Running nightly automation..." echo "Running xxxx script..." SUCCESS=`/home/server/scripts/xxxx.sh &amp;&amp; echo 1` if [ $SUCCESS -eq 1 ]; then         echo "xxxx success!" else         echo "xxxx fail!" fi echo "Running rsync..." /usr/bin/rsync -am --remove-source-files /path1/ /path2/ --log-file=/home/server/logs/sync.log &amp;&amp; echo "rsync success!"
70961
I am looking for a method built-in to ubuntu that will allow me to run a script or program or whatever for a fixed period of time.  , but the package is unavailable for Ubuntu. In any case, I was hoping for something built-in.  The only thing i can think of is to get the current time and set a cron job 30 minutes from 'now' that will kill the program.  I was hoping there was a way to do this without setting up a script, but if I need to - it wont be the end of the world. After the 30 minute interval I would like to put my laptop in a sleep mode, but this can be separate from the timer thing.  Thanks in advance.
85797
How can one configure MacOS (10.8 or higher) to automatically and immediately call a user-designated script (probably a bash script) upon the user closing the display lid of a MacBook Air or Pro?  Details.  I want to do this because in some scenarios my MacBook Air 2013 running 10.8.5 does not immediately sleep/lock the screen upon lid close (possibly because a VPN client is trying to open a connection).  As such, I want the system to immediately execute a script which calls  upon lid close.  However, I don't know how to call scripts upon display-lid closing.
52811
I have a notify.sh script that looks like:  notify-send "hi welcome"   My crontab notification for 2 PM:  0 14 * * * home/hacks/notify.sh   However, this doesn't work. What is the problem?
39337
I have a script that I would like to run as a service on my Ubuntu Server 11.04 headless box. That is, I want to have the correct files under /etc/init.d/ and to be able to control it via the service command.  Is there any guide available that will show me how to do this?
87617
I'm accustomed to running scripts on boot in Linux, but I'm not sure how to do this in Android. I'd like to start my SSH daemon on start, so I'll always be able to connect. How can I run an arbitrary script on Android boot? It'd be preferable to do this outside of Dalvik.
95932
I want to start a script, which set the system time automatically after booting. I wrote the command date -s "12/31/12 23:59" in rc.d/rc.local. That didn't work. How to solve that?