Friday, October 25, 2013

Bing! Rewards Automation script: Unix Cron

I developed Bing! Rewards Automation script to automate the process of gaining Bing! rewards. Then I enhanced it to version 3.0 to automate the script execution and retries and to be notified on custom events. Now I want to share the recipe of full automation - that is when you don't run the script manually, but it is cronned in your favorite flavor of Unix/Linux.

For security reasons it's better to create a new user - a system user, so to say. The only purpose of that user will be to run the Bing! Rewards Automation script:
# useradd -mU bingrewards
useradd creates a new user named bingrewards (lower-case by convention), creates a home directory for it and also creates a group with the same name and includes the user into it.

Now do
# passwd bingrewards
To change the password.
Finally log into the user's account:
$ su bingrewards
Now you need to clone Bing! Rewards automation git repository:
$ git clone -- ~/bin
$ cd ~/bin
$ chmod 600 config.xml
$ vim config.xml
The first line clones git repo into /home/bingrewards/bin.
The third line changes permissions so that only user bingrewards and root can read and/or write config.xml.
With the last line you may want to edit your config.xml with your configuration using this documentation.

Finally, the last thing to do is:
$ mkdir -p ~/var/log/bingrewards
$ crontab -e
and paste this into your crontab:

0   1   *   *   *   sleep $(($RANDOM \% 120))m && python2 /home/bingrewards/bin/ 2>&1 | gzip > /home/bingrewards/var/log/bingrewards/`date "+\%Y-\%m-\%dT\%H:\%M:\%S"`.log.gz
Where the first line sets PATH environment variable, which consists of directories to traverse to find an executable. /usr/bin is where sleep, python2, gzip and date sit in my Linux distribution.
LOCAL_CONFIG_DIR is an environment variable which is used in notify/ and notify/ of the standard Bing! Rewards Automation script distribution (version 3.0). There sits a file of format:
Finally, the last line of crontab sets the cron job which runs at 1 am every day. The cron job consists of three steps:

  1. sleep up to 120 minutes. This sleep is introduced not to attract too much attention from Bing! and can be omitted. For more information see this blog post.
  2. run the script itself. 2>&1 says output STDERR to STDOUT that is if exception occurs it will be in STDOUT.
  3. gzip STDOUT and put it in /home/bingrewards/var/log/bingrewards/ creating a file like 2013-10-25T04:30:01.log.gz

    This last line essentially creates a log - just in case if there is something interesting which you may want to look up later. Gzip creates an archive to save the disc space, because it's not so likely that you want to have an uncompressed log. Also, consider zless, zcat, zgrep to work with logs. Vim can open gzipped text files as well.

    From crontab man:
    The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
    that is why % characters are escaped.

With all this randomness Bing! Rewards Automation script is almost completely undiscoverable. There is a random sleep between queries, a random sleep after completing one account and starting another and finally there is a random sleep every day before the script starts. All that together highly increases the odds against identifying the script as a bot by Bing!

Happy Binging :)


  1. If I'm not mistaken, you have an escape character in your sleep command

    sleep $(($RANDOM \% 120))m should instead be sleep $(($RANDOM % 120))m

    1. Please, read "From crontab man" section above once again.

    2. Sorry about that. I guess that's what happens when you jump strait to code without reading completely.

  2. Hi I recently tried your script and I think I set everything up correctly because for my outlook/hotmail accounts it does the searches and everything but on my facebook account I get 3 authentication errors and then it moves on the the next account. I was wondering if anyone knew why that was

    1. also when you are talking about sending the automatic email notification you say what a file format is but I can't for the life of me find the file that contains that "format"

    2. You get 3 auth errors for your Facebook account because either login or password are not correct for your FB account - double check that.

      If you open up notify/ and/or notify/ from the project dir, you'll see

      source "${LOCAL_CONFIG_DIR}/"

      So, in the post above I say what that file should look like if you use my solution out-of-the box.

      Also, you don't have to stick to that same notification hooks, those can be arbitrary scripts or executables. Read the documentation: []

      And in that same documentation you may find an information how to setup retries and conditions when to retry.

  3. Hi whenever I run the script each time an account "finishes" i get a syntax error: "(" unexpected I believe it corresponds to the function usage() part of but I don't know how to fix this error or why it is occuring

    1. Mitigation: comment the notifications out in config.xml
      Solution: as you might understand, it's impossible to understand what happened from what you've posted here. Please, add an extra information -- the complete error string. OS type (uname -a [if Linux]). Script version ( --version). Python version (python --version)

    2. It seems that I was getting the error because my OS didn't like the #!/bin/sh thing in the beginning of scripts. (sorry im very knew to all this so i don't know what the correct term for that is) Anyway I changed it to #!/bin/bash and it fixed the problem. I am running on Debian

    3. #!/bin/sh
      as a first line tells the shell it should try feeding the further text to that engine if the file has executable flag for the current user. The same way you may see:
      and others. It is a recommendation to the shell. In your case I don't quite understand why #!/bin/sh doesn't work. Can you do
      $ /bin/sh --version
      and post the output here?

  4. This comment has been removed by the author.

  5. put the following line as the first line of your crontab


  6. I stumbled on this while researching Bing Search Automation. I was working with BS4 yesterday and wondered if there was a way to Automate searches and get rewards.